diff options
Diffstat (limited to 'node_modules/moment/src/lib/locale')
-rw-r--r-- | node_modules/moment/src/lib/locale/locales.js | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/node_modules/moment/src/lib/locale/locales.js b/node_modules/moment/src/lib/locale/locales.js index 7d8fb26e0..af28bfe27 100644 --- a/node_modules/moment/src/lib/locale/locales.js +++ b/node_modules/moment/src/lib/locale/locales.js @@ -42,7 +42,7 @@ function chooseLocale(names) { } i++; } - return null; + return globalLocale; } function loadLocale(name) { @@ -77,6 +77,12 @@ export function getSetGlobalLocale (key, values) { // moment.duration._locale = moment._locale = data; globalLocale = data; } + else { + if ((typeof console !== 'undefined') && console.warn) { + //warn user if arguments are passed but the locale could not be set + console.warn('Locale ' + key + ' not found. Did you forget to load it?'); + } + } } return globalLocale._abbr; @@ -84,7 +90,7 @@ export function getSetGlobalLocale (key, values) { export function defineLocale (name, config) { if (config !== null) { - var parentConfig = baseConfig; + var locale, parentConfig = baseConfig; config.abbr = name; if (locales[name] != null) { deprecateSimple('defineLocaleOverride', @@ -97,14 +103,19 @@ export function defineLocale (name, config) { if (locales[config.parentLocale] != null) { parentConfig = locales[config.parentLocale]._config; } else { - if (!localeFamilies[config.parentLocale]) { - localeFamilies[config.parentLocale] = []; + locale = loadLocale(config.parentLocale); + if (locale != null) { + parentConfig = locale._config; + } else { + if (!localeFamilies[config.parentLocale]) { + localeFamilies[config.parentLocale] = []; + } + localeFamilies[config.parentLocale].push({ + name: name, + config: config + }); + return null; } - localeFamilies[config.parentLocale].push({ - name: name, - config: config - }); - return null; } } locales[name] = new Locale(mergeConfigs(parentConfig, config)); |