MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / defineLocale

Function defineLocale

tests/test_code/js/moment/moment.js:2131–2183  ·  view source on GitHub ↗
(name, config)

Source from the content-addressed store, hash-verified

2129 }
2130
2131 function defineLocale(name, config) {
2132 if (config !== null) {
2133 var locale,
2134 parentConfig = baseConfig;
2135 config.abbr = name;
2136 if (locales[name] != null) {
2137 deprecateSimple(
2138 'defineLocaleOverride',
2139 'use moment.updateLocale(localeName, config) to change ' +
2140 'an existing locale. moment.defineLocale(localeName, ' +
2141 'config) should only be used for creating a new locale ' +
2142 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'
2143 );
2144 parentConfig = locales[name]._config;
2145 } else if (config.parentLocale != null) {
2146 if (locales[config.parentLocale] != null) {
2147 parentConfig = locales[config.parentLocale]._config;
2148 } else {
2149 locale = loadLocale(config.parentLocale);
2150 if (locale != null) {
2151 parentConfig = locale._config;
2152 } else {
2153 if (!localeFamilies[config.parentLocale]) {
2154 localeFamilies[config.parentLocale] = [];
2155 }
2156 localeFamilies[config.parentLocale].push({
2157 name: name,
2158 config: config,
2159 });
2160 return null;
2161 }
2162 }
2163 }
2164 locales[name] = new Locale(mergeConfigs(parentConfig, config));
2165
2166 if (localeFamilies[name]) {
2167 localeFamilies[name].forEach(function (x) {
2168 defineLocale(x.name, x.config);
2169 });
2170 }
2171
2172 // backwards compat for now: also set the locale
2173 // make sure we set the locale AFTER all child locales have been
2174 // created, so we won't end up with the child locale set.
2175 getSetGlobalLocale(name);
2176
2177 return locales[name];
2178 } else {
2179 // useful for testing
2180 delete locales[name];
2181 return null;
2182 }
2183 }
2184
2185 function updateLocale(name, config) {
2186 if (config != null) {

Callers 1

getSetGlobalLocaleFunction · 0.85

Calls 4

deprecateSimpleFunction · 0.85
loadLocaleFunction · 0.85
mergeConfigsFunction · 0.85
getSetGlobalLocaleFunction · 0.85

Tested by

no test coverage detected