Example:
const amount = 12345.67
const options = {style: 'currency', currency: 'EUR'}
amount.toLocaleString('de-DE', options)
-> '€ 12,345.67'
should be
'12.345,67 €'
(Be aware that the grouping separator for DE is also wrong!)
This happens only when using currency localisation
Reference: Chrome v53 performs correctly
/cc @nodejs/intl
@odotom the cause is a lack of locale data. see https://github.com/nodejs/node/wiki/Intl
With the right data I get
$ node -v
6.5.0
$ npm i full-icu
…… node --icu-data-dir=node_modules/full-icu ………
$ node --icu-data-dir=node_modules/full-icu
> const amount = 12345.67
> const options = {style: 'currency', currency: 'EUR'}
> amount.toLocaleString('de-DE', options)
'12.345,67 €'
Do let me know if you have issues or questions about the data, but as an issue I'm closing it.
Thnx, has to be considered for server side rendering!
Node.js, by default, only includes the data files for the English locale. It is possible to download the full data set using the full-icu module.
@odotom updated my reply above w/ more about using full-icu
@srl295 This is still broken. The options minimumFractionDigits and maximumFractionDigits are not working correctly.
Consider the numbers 1234.00001 and 1234.123456:
// outputs '1,234.00' instead of '1,234.000'
// the defaul of maximum is max(minimumFractionDigits, 3) so it should ouput 3 zeros
1234.00001.toLocaleString('en-GB', {useGrouping: true, minimumFractionDigits: 2})
// correctly outputs '1,234.123'
1234.123456.toLocaleString('en-GB', {useGrouping: true, minimumFractionDigits: 2})
Most helpful comment
@odotom the cause is a lack of locale data. see https://github.com/nodejs/node/wiki/Intl
With the right data I get
Do let me know if you have issues or questions about the data, but as an issue I'm closing it.