ECMAScript Internationalization API with node

僤鯓⒐⒋嵵緔 提交于 2019-12-20 03:39:13

问题


Is there a way to use the ECMAScript Internationalization API with nodejs?

For now, i only need the timezone support:

new Date().toLocaleString("en-US", {timeZone: "America/New_York"})

which works very well with chrome, but not with node. Are there any options like --harmony to activate it?


回答1:


Internationalization is turned off in v8 when built for node.js. The reason is that the library that provides it significantly increases the size of the node binary for a small perceived gain. You can turn it back on if you're willing to build node from source. First you'll have to check out the github repo (https://github.com/joyent/node) and then do the following from the repo root:

svn checkout --force --revision 214189 \
    http://src.chromium.org/svn/trunk/deps/third_party/icu46 \
    deps/v8/third_party/icu46
./configure --with-icu-path=deps/v8/third_party/icu46/icu.gyp
make
make install

These instructions are from the README.md of that repo, which can be read at https://github.com/joyent/node



来源:https://stackoverflow.com/questions/23571043/ecmascript-internationalization-api-with-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!