I changed moments locale by setting the following property:
moment.locale(chosenLocale);
Everything seems to work fine. I get the month names and the weekday names according to the selected locale. I also get correct calculation of weeknumber etc.
With default (english) locale i get month names like January, February, etc. I also get weekday names like Monday, Tuesday, etc. For some reason, with danish locale i get all these names lowercased. When formatting a simple weekday, i can just capitalize the first letter but for some more advanced formats where the name might swap order (January 1st vs. 1. Januar) i can't just uppercase the first letter.
I'm using this format to display the month name and day of month:
moment().format('dddd LL')
In danish i get 7. marts 2016 but i really want 7. Marts 2016. Keep in mind, i need the solution to work on all locales, so i can't hardcode the month names - or can I? I tried the following:
moment.locale(chosenLocale);
var __months = moment.months().map(function (m) { return m.toUpperCase() + "TEST"; });
moment.locale(chosenLocale, {
months : __months
});
I would expect (for testing purposes) to get JANUARTEST for danish locale, but i get januartest which hints that the lower case is applied by the framework somewhere else. I also tried to set the months property to a function according the the api docs and then return the uppercase value of the cached month array, which same result as described.
Does anyone have a solution to this?