moment.locale(String);
在 NodeJS 中加载语言环境非常简单。
如果 moment-root/locale/ 中有一个以该键命名的语言环境文件,则对 moment.locale 的第一次调用将会加载该文件。
var moment = require('moment');
moment.locale('fr');
moment(1316116057189).fromNow(); // il y a une heure
如果希望你的语言环境受支持,则使用所需的语言环境和单元测试文件创建一个对 develop 分支的 pull request。
moment.locale(String);
Loading locales in NodeJS is super easy. If there is a locale file in moment-root/locale/ named after that key, the first call to moment.locale will load it.
var moment = require('moment');
moment.locale('fr');
moment(1316116057189).fromNow(); // il y a une heure
If you want your locale supported, create a pull request to the develop branch with the required locale and unit test files.