带节点的ECMAScript国际化API [英] ECMAScript Internationalization API with node

查看:96
本文介绍了带节点的ECMAScript国际化API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将 ECMAScript国际化API 与nodejs一起使用?

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"})

与chrome搭配使用时效果很好,但与node搭配则不然. 是否有--harmony之类的选项可以将其激活?

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

推荐答案

为node.js构建时,v8中的国际化已关闭.原因是提供该库的库显着增加了节点二进制文件的大小,从而获得了较小的感知增益.如果您愿意从源代码构建节点,则可以将其重新打开.首先,您必须签出github仓库( https://github.com/joyent/node ),然后从回购根目录执行以下操作:

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

这些说明来自该存储库的README.md,可以在 https://github.com上阅读./joyent/node

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

这篇关于带节点的ECMAScript国际化API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆