1$i18n = (function() { 2 var locale_strings = {}, 3 locale = 'en'; 4 5 function __(msgid, variables) { 6 return __d('default', msgid, variables); 7 } 8 9 function __d(domain, msgid, variables) { 10 var string = (locale_strings.hasOwnProperty(domain) && locale_strings[domain].hasOwnProperty(msgid)) ? locale_strings[domain][msgid] : msgid; 11 12 if (typeof variables === 'object' && variables instanceof Array) { // Replace as array 13 for(var i = 0, ii = variables.length; i < ii; i++) { 14 string = string.replace(new RegExp('{' + i + '}', 'g'), variables[i]); 15 } 16 } else if (typeof variables === 'object' && variables instanceof Object) { // Replace as dictionary 17 for(var key in variables) { 18 if (variables.hasOwnProperty(key)) { 19 string = string.replace(new RegExp('{' + key + '}', 'g'), variables[key]); 20 } 21 } 22 } 23 24 return string; 25 } 26 27 function getLocale() { 28 return locale; 29 } 30 31 function setLocale(lang) { 32 locale = lang; 33 } 34 35 function setLocaleStrings(dict) { 36 locale_strings = dict; 37 } 38 39 function url(base_url) { 40 if (locale === 'en') return base_url; 41 return '/' + locale + base_url; 42 } 43 44 // Public functions & variables 45 return { 46 '__': __, 47 '__d': __d, 48 'getLocale': getLocale, 49 'setLocale':setLocale, 50 'setLocaleStrings': setLocaleStrings, 51 'url': url 52 }; 53})(); 54 55// Expose the localization functions to the global scope 56__ = $i18n.__; 57__d = $i18n.__d;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.