0

I've noticed that en-FR does not appear to be a fully supported locale by the Intl.NumberFormat API.

I've not found any official list of supported locales by the Intl api. However, I can assume the list from a fairly popular polyfill by formatjs

That list of supported locales does not include en-FR. Maybe I'm being naive but I think this locale would be a commonly supported locale, for example for users who speak English but are in a French region.

const numberFormatter = Intl.NumberFormat('en-FR');

//numberFormatter.resolvedOptions()
{
    "locale": "en",
    "numberingSystem": "latn",
    "style": "decimal",
    "minimumIntegerDigits": 1,
    "minimumFractionDigits": 0,
    "maximumFractionDigits": 3,
    "useGrouping": "auto",
    "notation": "standard",
    "signDisplay": "auto",
    "roundingMode": "halfExpand",
    "roundingIncrement": 1,
    "trailingZeroDisplay": "auto",
    "roundingPriority": "auto"
}

//numberFormatter.formatToParts(1234.56)
1,234.56 

When a new Intl.NumberFormat is contrusted with the en-FR locale, it appears to fallback to just a en locale. This is problematic as the en locale will produce a different number format than an en-FR locale would:

Locale Input Expected Output
en-FR 12345.56 1 234,56
en 12345.56 1,2345.56

Is there any way to control the decimal or group characters of the Intl.NumberFormat API? Or is there any way to add a custom locale support?

The use case stems from the iOS ecosystem, where a user may have a language of locale en-GB, but a region setting of en-FR. The numbers, dates, currencies should reflect the "France" region, but the actual translations should reflect the "English (United Kingdom)" language.

tnort173
  • 348
  • 1
  • 4
  • 17
  • 1
    There is no `en-FR` because there is no french dialect of english – Konrad Nov 20 '22 at 18:08
  • do you mean `fr`? see [Complete list of all different Intl.NumberFormats](https://stackoverflow.com/questions/48273724/complete-list-of-all-different-intl-numberformats) for discussion about locale references. Also [LocalePlanet](https://www.localeplanet.com/icu/en/index.html) – pilchard Nov 20 '22 at 18:11
  • @Konrad That’s correct, but supplying the “en-FR“ should utilize the region code (“FR”) with concern to how numbers, dates, and currency are formatted, no? – tnort173 Nov 20 '22 at 19:20

0 Answers0