(name, config)
| 16594 | } |
| 16595 | |
| 16596 | function defineLocale (name, config) { |
| 16597 | if (config !== null) { |
| 16598 | var locale, parentConfig = baseConfig; |
| 16599 | config.abbr = name; |
| 16600 | if (locales[name] != null) { |
| 16601 | deprecateSimple('defineLocaleOverride', |
| 16602 | 'use moment.updateLocale(localeName, config) to change ' + |
| 16603 | 'an existing locale. moment.defineLocale(localeName, ' + |
| 16604 | 'config) should only be used for creating a new locale ' + |
| 16605 | 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'); |
| 16606 | parentConfig = locales[name]._config; |
| 16607 | } else if (config.parentLocale != null) { |
| 16608 | if (locales[config.parentLocale] != null) { |
| 16609 | parentConfig = locales[config.parentLocale]._config; |
| 16610 | } else { |
| 16611 | locale = loadLocale(config.parentLocale); |
| 16612 | if (locale != null) { |
| 16613 | parentConfig = locale._config; |
| 16614 | } else { |
| 16615 | if (!localeFamilies[config.parentLocale]) { |
| 16616 | localeFamilies[config.parentLocale] = []; |
| 16617 | } |
| 16618 | localeFamilies[config.parentLocale].push({ |
| 16619 | name: name, |
| 16620 | config: config |
| 16621 | }); |
| 16622 | return null; |
| 16623 | } |
| 16624 | } |
| 16625 | } |
| 16626 | locales[name] = new Locale(mergeConfigs(parentConfig, config)); |
| 16627 | |
| 16628 | if (localeFamilies[name]) { |
| 16629 | localeFamilies[name].forEach(function (x) { |
| 16630 | defineLocale(x.name, x.config); |
| 16631 | }); |
| 16632 | } |
| 16633 | |
| 16634 | // backwards compat for now: also set the locale |
| 16635 | // make sure we set the locale AFTER all child locales have been |
| 16636 | // created, so we won't end up with the child locale set. |
| 16637 | getSetGlobalLocale(name); |
| 16638 | |
| 16639 | |
| 16640 | return locales[name]; |
| 16641 | } else { |
| 16642 | // useful for testing |
| 16643 | delete locales[name]; |
| 16644 | return null; |
| 16645 | } |
| 16646 | } |
| 16647 | |
| 16648 | function updateLocale(name, config) { |
| 16649 | if (config != null) { |
no test coverage detected