Every line of 'javascript get locale' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
128 function getStringForCurrentLocale(locales) { 129 var locale = ( 130 document.documentElement.lang || 131 navigator.language|| 132 navigator.userLanguage 133 ).substr(0, 2); 134 135 return (locales[locale]) ? locales[locale] : locales['en']; 136 }
128 function getStringForCurrentLocale(locales) { 129 var locale = ( 130 document.documentElement.lang || 131 navigator.userLanguage || 132 navigator.language 133 ).substr(0, 2); 134 135 return (locales[locale]) ? locales[locale] : locales['en']; 136 }
33 function getLocale(lang) { 34 if (typeof lang !== "string") { 35 lang = "en"; 36 } 37 lang = lang.toLowerCase(); 38 if (locale.hasOwnProperty(lang) && 39 locale[lang] !== false) { 40 return locale[lang]; 41 } 42 else { 43 if (!locale.hasOwnProperty(lang)) { 44 locale[lang] = false; 45 console.log("Warning: Localization not found for language '" + 46 lang + "'"); 47 } 48 return locale.en; 49 } 50 }
195 export function getLocale(locale) { 196 return registry.locales[locale]; 197 }
19 export function getLocale() { 20 return locale || 'en'; 21 }
36 function getDefaultLocale(locale) { 37 return defaultLocales[locale] || defaultLocales['*']; 38 }
61 function getLocale() { 62 var DEFAULT_VALUE = 'zh'; /* 默认设置为中文 */ 63 return navigator.language || navigator.userLanguage || navigator.browserLanguage || navigator.systemLanguage || DEFAULT_VALUE; 64 }
123 function getLocale(locale) { 124 return (locale || '').toLowerCase() 125 }
36 return function get(key: string, ...args: any[]) { 37 let content = texts[key] || macroTexts[key] || defaults[key] || key 38 39 if (args.length) { 40 args.forEach((arg, index) => { 41 content = content.replace(new RegExp(`\\{${index}\\}`, 'g'), arg == null ? '' : arg) 42 }) 43 } 44 45 return content 46 }
81 get(str) { 82 let res; 83 if (typeof strings[this.locale] === 'undefined' || typeof strings[this.locale][str] === 'undefined') { 84 res = strings['en'][str]; 85 console.log('Localization of "' + str + '" in "' + this.locale + '" failed, falling back to English.'); 86 } else { 87 res = strings[this.locale][str]; 88 } 89 return res; 90 }