Search code examples
node.jsecmascript-intl

ECMAScript Internationalization API with node


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?


Solution

  • 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