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

Function updateLocale

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

Source from the content-addressed store, hash-verified

2183 }
2184
2185 function updateLocale(name, config) {
2186 if (config != null) {
2187 var locale,
2188 tmpLocale,
2189 parentConfig = baseConfig;
2190
2191 if (locales[name] != null && locales[name].parentLocale != null) {
2192 // Update existing child locale in-place to avoid memory-leaks
2193 locales[name].set(mergeConfigs(locales[name]._config, config));
2194 } else {
2195 // MERGE
2196 tmpLocale = loadLocale(name);
2197 if (tmpLocale != null) {
2198 parentConfig = tmpLocale._config;
2199 }
2200 config = mergeConfigs(parentConfig, config);
2201 if (tmpLocale == null) {
2202 // updateLocale is called for creating a new locale
2203 // Set abbr so it will have a name (getters return
2204 // undefined otherwise).
2205 config.abbr = name;
2206 }
2207 locale = new Locale(config);
2208 locale.parentLocale = locales[name];
2209 locales[name] = locale;
2210 }
2211
2212 // backwards compat for now: also set the locale
2213 getSetGlobalLocale(name);
2214 } else {
2215 // pass null for config to unupdate, useful for tests
2216 if (locales[name] != null) {
2217 if (locales[name].parentLocale != null) {
2218 locales[name] = locales[name].parentLocale;
2219 if (name === getSetGlobalLocale()) {
2220 getSetGlobalLocale(name);
2221 }
2222 } else if (locales[name] != null) {
2223 delete locales[name];
2224 }
2225 }
2226 }
2227 return locales[name];
2228 }
2229
2230 // returns locale data
2231 function getLocale(key) {

Callers

nothing calls this directly

Calls 3

mergeConfigsFunction · 0.85
loadLocaleFunction · 0.85
getSetGlobalLocaleFunction · 0.85

Tested by

no test coverage detected