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

Function loadLocale

tests/test_code/js/moment/moment.js:2079–2101  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

2077 }
2078
2079 function loadLocale(name) {
2080 var oldLocale = null,
2081 aliasedRequire;
2082 // TODO: Find a better way to register and load all the locales in Node
2083 if (
2084 locales[name] === undefined &&
2085 typeof module !== 'undefined' &&
2086 module &&
2087 module.exports
2088 ) {
2089 try {
2090 oldLocale = globalLocale._abbr;
2091 aliasedRequire = require;
2092 aliasedRequire('./locale/' + name);
2093 getSetGlobalLocale(oldLocale);
2094 } catch (e) {
2095 // mark as not found to avoid repeating expensive file require call causing high CPU
2096 // when trying to find en-US, en_US, en-us for every format call
2097 locales[name] = null; // null means not found
2098 }
2099 }
2100 return locales[name];
2101 }
2102
2103 // This function will load locale and then set the global locale. If
2104 // no arguments are passed in, it will simply return the current global

Callers 4

chooseLocaleFunction · 0.85
defineLocaleFunction · 0.85
updateLocaleFunction · 0.85
getLocaleFunction · 0.85

Calls 1

getSetGlobalLocaleFunction · 0.85

Tested by

no test coverage detected