简体   繁体   中英

How to change angular-moment locale?

I'm trying to use French version of moment, but moment.locale('fr') doesn't work and it doesn't change the language:

console.debug(moment.locale()); 
moment.locale('fr'); 
console.debug(moment.locale());
console.debug(moment.locales());

output :

en
en
TypeError: moment.locales is not a function

gulpfile.js:

var path={
    js:
    [
        {
            src:
                [
                    'bower_components/moment/min/moment.min.js',
                    'bower_components/moment/locale/fr.js',
...

You need to import the french definition

import 'moment/locale/fr'
moment.locale('fr')

https://momentjs.com/docs/#/i18n/loading-into-browser/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM