I am trying to change the language of the date which is being set by moment.js. The default one is English, but I want to set the German language. These is what I tried:
I'm using angular2-moment, but usage must be similar.
import { MomentModule } from "angular2-moment";
import moment = require("moment");
export class AppModule {
constructor() {
moment.locale('ru');
}
}
For me, there are some changes to make(ver. 2.20)
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.So that means:
moment.locale('de');
var now = moment();
now.format('LLL');
moment-with-locale.js
. The file contains all locale info and has a larger file size. Download the locale
folder is not enough. If necessary, change the name to be moment.js
. Django just refuses to load moment-with-locale.js
in my case.EDIT: It turned out that renaming the file is not necessary. I just forgot to invoke it in the page so Django does not think loading it is necessary, so my fault.