ECMAScript国际化API与节点
有没有办法与nodejs一起使用ECMAScript国际化API ?
现在,我只需要时区支持:
new Date().toLocaleString("en-US", {timeZone: "America/New_York"})
这对于Chrome来说效果很好,但是不能和节点一起使用。 有没有像–harmony这样的选项来激活它?
为node.js构build的国际化在v8中被closures。 原因在于提供该库的库显着增加了节点二进制文件的大小,以获得小的感知增益。 如果您愿意从源代码构build节点,则可以将其重新打开。 首先,您必须查看github回购( https://github.com/joyent/node ),然后从回购根目录执行以下操作:
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