In my browser console:
> Intl.NumberFormat.supportedLocalesOf('it')
["it"]
In node on my computer:
> Intl.NumberFormat.supportedLocalesOf('it')
[]
In node on my coworkers computer:
> Intl.NumberFormat.supportedLocalesOf('it')
["it"]
Same versions of node 4.5.0
Where is the Intl.NumberFormat support supposed to come from? What do you have to build to get it included in your version of node?
By default, node builds in only a reduced set of ICU data (English only) due to file size.
If you're already building node manually, if you ./configure --with-intl=full-icu
you will get the full ICU data set built-in. You can also use --with-intl=system-icu
to have node use the OS ICU data.
If you're installing from some other (non-nodejs.org) source, such as an OS distribution repository, you will need to contact the maintainer of such binaries about providing builds with full-icu/system-icu.
One last option is to install the full-icu
module, which will make the full-icu data set available.
From https://github.com/nodejs/node/wiki/Intl
What is Intl?
EcmaScript 402 describes the global Intl (short for Internationalization) object and other related functions and functionality.
Node.js (or more properly, the v8 engine) uses ICU4C to implement this Intl support in native C/C++. ICU's source is not included with Node's source repository or source distributions.
See also https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Intl
The Intl object is the namespace for the ECMAScript Internationalization API, which provides language sensitive string comparison, number formatting, and date and time formatting. The constructors for Collator, NumberFormat, and DateTimeFormat objects are properties of the Intl object. This page documents these properties as well as functionality common to the internationalization constructors and other language sensitive functions.
I see that I don't have Intl
in Node 5.12.0 but I do have it by default in Node 6.5.0.
It may have been added in 6.0.0: https://nodejs.org/en/blog/release/v6.0.0/
[cdba9a6c02] - src: add intl and icu configs to process.binding('config') (James M Snell) #6266
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With