-
Notifications
You must be signed in to change notification settings - Fork 215
Intl.js on Node 4.2 #140
Comments
node 4 supports Intl, which means the polyfill will opt-out automatically. The catch is that it comes with english locale only, and you need to setup node to enable the right locales for your app. Here is the doc: https://github.com/nodejs/node/wiki/Intl |
So, that means I'll have to compile node myself instead of using the version apt/brew contains. Intl.js' Readme currently says:
You might want to update that 😄 |
Anything related to Intl in node should be discussed here: https://github.com/nodejs/Intl/issues, I don't think you need to compile node, in most cases it is just a configuration option, plus we are working on using As for the readme, that is correct, node 0.12 also supports Intl, but that one will require you to compile node with extra options. The polyfill knows how to deal with 0.12 if you haven't compiled node. |
I'm having a similar issue, and I don't understand the response. The gist shows that that polyfill would be active because it is using a non-English locale. Can you help me understand why this is? It's just doing the language polyfills, not the entire Intl object. The README doesn't really make it clear that additional steps are necessary for this to work. Using the same code from the gist in my app:
Node 4.4.0, Intl 1.0.1:
I also see that with Intl 1.0.1, the default locale appears to be "af-NA" instead of "en-US" like it is in Intl 0.1.4. Is that expected? |
I'm also not seeing localized output form the Date/Number prototypes ( As illustrated here: It seems like a bug in Node.js. If |
that gist is not polyfilling Data/Number in node because of line 4 (https://gist.github.com/twalker/d33941123b89fe28c059931679994673#file-intl-node-protoype-example-js-L4), that condition will be false since Intl is in fact available. You can relax that condition to not only check if Intl is available or not, but also testing if the default Intl supports all locales that your app should support, and you go from there. Alternative, if you know that the default Intl is not what you need, replace it entirely with the polyfill by doing global.Intl = global.IntlPolyfill, although that's not recommended. |
I'm talking about the original gist at the top of this issue, which follows the guidelines of the README and loads the polyfills for non-English locales. |
On one machine, I've recently updated from node 0.10 to node 4.2.1. Now, calling
toLocaleString
does not use the correct locale anymore. Is this a known issue with a newer node version?You can find a demo of the issue here: https://gist.github.com/killercup/9880e1af193311cb4734
The text was updated successfully, but these errors were encountered: