如何在meteor.js中本地化(i18n)moment.js? [英] How to localize (i18n) moment.js within meteor.js?
问题描述
如何在meteor.js应用程序中使用moment.js来使用除英语之外的其他语言? moment.js(安装为mrt包)可以使用默认的英语语言。
How can moment.js used within a meteor.js app be told to use another language than English? moment.js (installed as an mrt package) works fine with the default English language.
在 http://momentjs.com/docs/#/i18n/changing-language/ 总是生成'en'。我注意到meteor_project / packages / moment / lib / moment / lang / de.js中有一个德语语言文件似乎没用过吗?
Using the demo calls from the moment.js docs at http://momentjs.com/docs/#/i18n/changing-language/ always produces 'en'. I noticed there is a German language file for moment in meteor_project/packages/moment/lib/moment/lang/de.js that doesn't seem to be used though?
要指定:在模板助手中我尝试过:
moment.lang('de');
返回moment.lang()//将导致'en'
To specify: within a template helper I tried: moment.lang('de'); return moment.lang() //will result to 'en'
以及此处提到的其他选项:从Meteor中的Handlebars模板内部格式化日期
and the other options mentioned here: Format a date from inside a Handlebars Template in Meteor
推荐答案
如果您安装时刻
为
mrt add moment
然后你已经掌握了语言,但你必须手动包含它们。在 packages\moment\lib\lang
中找到它们。要包含它们,请转到 package.js
文件,并在所有其他文件后添加您选择的语言。
Then you already got the languages, but you have to include them manually. Find them at packages\moment\lib\lang
. To include them, go to the package.js
file and add the language of your choice after all the other files.
api.add_files('lib / moment / lang / de.js','client')
你去吧!
这篇关于如何在meteor.js中本地化(i18n)moment.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!