I’m using the the bootstrap3 datetimepicker from
which relies on momentjs. I am trying to get it to use en-gb locale so that dates will be display as dd/mm/yyyy but it doesn’t work. So I have tried drilling down to setting locales directly on moment() and (both mrt:moment and momentjs:moment) but locales just don’t seem to work.
When I look in Chrome inspect at the sources the locales files don’t seem to be there?
I also had trouble getting moment locales to work.
Got it working by placing my
moment-nl.js deep down in
/lib/config and calling
moment.locale('nl'); from Meteor.startup.
Thanks, I’ll try that. Is it important that it goes in a ‘config’ folder?
/lib is ok too, it’s just where I use to keep these sort of things…
I guess as many others, I had to solve this exact same problem for LibreBoard — which is available in 6 languages. For this purpose I forked the official
momentjs package and included all translation files as package “assets”. When the
TAPi18n locale is changed, I reactively download the translation file (using
$.ajax) and configure it (see implementation). As far as I can tell it works perfectly well
I published my fork in github https://github.com/mquandalle/moment, and atmosphere
mquandalle:moment. At some point I hope we could merge my changes back in the official package.
This works perfect, thanks
You need to add the language files and then call moment.locale();
I’m struggling with this as well. I’d like ‘en-ie’ (not that it differs much from ‘en-gb’ ). I did the following:
Downloaded en-ie.js from github and placed it in my /lib directory.
Then in my lib/init.js I call moment.locale(‘en-ie’);
Now on the server it works. moment.locale() returns ‘en-ie’ and moment().format(‘L’) returns DD/MM/YYYY.
But on the client moment.locale() returns ‘en’ and likewise the date is MM/DD/YYYY.
If in the console I type moment.locale(‘en-ie’) again then it all works so I suspect moment locale on the client is being overridden after startup. I added some console.log straight after setting it in startup and it does get set, but something is setting it back to plain ‘en’ sometime thereafter.
Anyone know anything about this?
As so often happens, the solution comes straight after posting.
I had included risul:moment-timezone. By removing that and adding the mrt:moment-timezone it’s acting as expected.
Of course, this timezone implementation doesn’t have the moment.tz.setDefault() so now I have another problem.