【问题标题】:ECMAScript Internationalization API with node带节点的 ECMAScript 国际化 API
【发布时间】:2014-05-09 17:51:41
【问题描述】:

有没有办法将ECMAScript Internationalization API 与 nodejs 一起使用?

目前,我只需要时区支持:

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

它在 chrome 上运行得很好,但在 node.js 上却不行。 有没有像 --harmony 这样的选项来激活它?

【问题讨论】:

  • 虽然这不能回答您的问题,但标题暗示您需要 intl 模块。不幸的是,时区支持是剩余未实现的功能之一。

标签: node.js ecmascript-intl


【解决方案1】:

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

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

这些说明来自该 repo 的 README.md,可以在 https://github.com/joyent/node 阅读该文件

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-14
    • 2017-08-26
    相关资源
    最近更新 更多