-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intl.NumberFormat with 'en-CA' and 'CAD' doesn't behave like other implementations #15265
Comments
The way the ECMA-402 spec defines supportedLocalesOf is through the LookupSupportedLocales abstract operation, which allows requested locales to be added to the resulting array as long as the most general language tag (e.g. |
Looks like this has been answered. Closing, reopen if that is a mistake. |
Ok sure, I'll take that as a side effect then. |
Hi @TimothyGu , so my friend and I are on two different machines. Both of us are running |
One of you probably has the full-icu package installed, the other hasn't. |
I seem to have the same issue as @jnrepo but with en-AU |
So what is the solution to this? |
@jnrepo the probable reason why you don't have consistency on different machines is the locale of each machine. If one machine is using const formatterCA = new Intl.NumberFormat('en-CA', {
style: 'currency',
currency: 'CAD',
});
const formatterUS = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'CAD',
});
formatterCA.format(399) // $399.00
formatterUS.format(399) // CA$399.00 The same goes for the other way around, if you're using
|
8.4.0
Linux 6b594c82153b 4.9.41-moby deps: update openssl to 1.0.1j #1 SMP Wed Sep 6 00:05:16 UTC 2017 x86_64 GNU/Linux
Ubuntu (From Docker image node:8.4.0)
Node behaves differently wrongly when formatting the 'CAD' currency using the 'en-CA' locale.
Node returns
CA$1.00
whereas other implementations return$1.00
.From Chrome:
From Firefox:
The polyfill behaves correctly:
I'm using the small-icu, so I know that only basic english is supported, so this is probably why
en-US
anden-CA
behave the same way:The polyfill page suggests to use the polyfill only if the locale is not supported, which makes sense, but according to Node,
en-CA
is supported:Since it's marked as supported, I'm using the default Intl, and then have a bug when displaying numbers, using
en-CA
. I am then forced to use the polyfill by default.Also, I first thought this was related to this issue (#15223), but I tried on an older version of node, and it does the same thing:
How do think it should behave here? Should
en-CA
be marked as not supported if using the small ICU? Or is that just a bug?The text was updated successfully, but these errors were encountered: