formatjs/intl-relativeformat

The original set of `locales` is not being passed through to the internal IntlMessageFormat instances

ericf opened this issue · 0 comments

I noticed a sneaky bug — because I use Safari which requires the Intl.js Polyfill — where numbers within relative formatted strings aren't being formatted with the exact locale the IntlRelativeFormat instance was created with.

An example is when using the Intl.js Polyfill and loading the fr-FR data, and creating an IntlRelativeFormat('fr-FR'). This ends up creating an internal IntlMessageFormat instance with only the root locale; i.e., IntlMessageFormat('fr'). Which then propagates that to creating Intl.NumberFormat('fr'), for which there's no data on the page and it falls back to English.

A change is required to propagate the original locales value the use specified when creating the IntlRelativeFormat instance all the way through the stack of format instances.