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.
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?
To specify: within a template helper I tried: moment.lang('de'); return moment.lang() //will result to 'en'
and the other options mentioned here: Format a date from inside a Handlebars Template in Meteor
You set locale with moment. locale('de') , and you create a new object representing the date of now by moment() (note the parenthesis) and then format('LLL') it. The parenthesis is important.
Moment construction falls back to js Date. This is discouraged and will be removed in an upcoming major release. This deprecation warning is thrown when no known format is found for a date passed into the string constructor.
lang(String[]); moment. lang(String, Object); By default, Moment. js comes with English (United States) locale strings. If you need other locales, you can load them into Moment.
The moment(). hour() Method is used to get the hours from the current time or to set the hours.
You can use rzymek's packages.
These packages use the offical momentjs:moment Meteor package.
Locales:
To add a specific locale user
meteor add rzymek:moment-locale-pl
The complete list of locales can be obtained by
meteor search rzymek:moment-locale-.*
To add all locales use:
meteor add rzymek:moment-locales
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With