diff options
author | Quoc Nghia Nguyen <quocnghia.nguyen@orange.com> | 2018-05-15 17:12:59 +0200 |
---|---|---|
committer | Quoc Nghia Nguyen <quocnghia.nguyen@orange.com> | 2018-05-16 11:07:13 +0200 |
commit | cc61d81601275dcd011dd76d5b52f585be3de7f3 (patch) | |
tree | 8436574ff6968bebdf166923aa4a356b07fbecf2 /apiroute/apiroute-service/src/main | |
parent | 4fd8cf8a708aecf23bc42274ca802bc8149d187a (diff) |
Make jquery.i18n fallback to en_US by default
- rewrite some comments in a proper order
- fix indentation
Change-Id: I452c14cc690acf91531b514a9b13953751b11346
Issue-ID: MSB-196
Signed-off-by: Quoc Nghia Nguyen <quocnghia.nguyen@orange.com>
Diffstat (limited to 'apiroute/apiroute-service/src/main')
-rw-r--r-- | apiroute/apiroute-service/src/main/resources/iui-route/js/jquery.i18n/jquery.i18n.properties-1.0.9.js | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/apiroute/apiroute-service/src/main/resources/iui-route/js/jquery.i18n/jquery.i18n.properties-1.0.9.js b/apiroute/apiroute-service/src/main/resources/iui-route/js/jquery.i18n/jquery.i18n.properties-1.0.9.js index 5f9b195..d7fb87d 100644 --- a/apiroute/apiroute-service/src/main/resources/iui-route/js/jquery.i18n/jquery.i18n.properties-1.0.9.js +++ b/apiroute/apiroute-service/src/main/resources/iui-route/js/jquery.i18n/jquery.i18n.properties-1.0.9.js @@ -65,21 +65,24 @@ $.i18n.properties = function(settings) { // load and parse bundle files var files = getFiles(settings.name); for(i=0; i<files.length; i++) { - // 1. load base (eg, Messages.properties) - //loadAndParseFile(settings.path + files[i] + '.properties', settings); - // 2. with language code (eg, Messages_pt.properties) - //if(settings.language.length >= 2) { - // loadAndParseFile(settings.path + files[i] + '-' + settings.language.substring(0, 2) +'.properties', settings); - //} - // 3. with language code and country code (eg, Messages_pt_PT.properties) - // 将寻找资源文件的顺序倒置 - if(settings.language.length >= 5) { - loadAndParseFile(settings.path + files[i] + '-' + settings.language.substring(0, 5) +'.properties', settings); - } else if(settings.language.length >= 2) { - loadAndParseFile(settings.path + files[i] + '-' + settings.language.substring(0, 2) +'.properties', settings); - } else { - loadAndParseFile(settings.path + files[i] + '.properties', settings); - } + // Look for the bundle files in the following order: + // 1. with language code and country code (eg, Messages_pt_PT.properties) + // 2. with language code (eg, Messages_pt.properties) + // 3. load base (eg, Messages.properties) + // 4. if none of the above is found, load en_US by default (eg, Messages_en_US.properties) + var xhrResult; + if (settings.language.length >= 5) { + xhrResult = loadAndParseFile(settings.path + files[i] + '-' + settings.language.substring(0, 5) + '.properties', settings); + } else if (settings.language.length >= 2) { + xhrResult = loadAndParseFile(settings.path + files[i] + '-' + settings.language.substring(0, 2) + '.properties', settings); + } else { + xhrResult = loadAndParseFile(settings.path + files[i] + '.properties', settings); + } + + if (xhrResult.status === 404) { + // fallback to en_US by default + loadAndParseFile(settings.path + files[i] + '-en-US.properties', settings); + } } // call callback @@ -245,15 +248,15 @@ $.i18n.browserLang = function() { /** Load and parse .properties files */ function loadAndParseFile(filename, settings) { - $.ajax({ - url: filename, - async: false, - cache: settings.cache, - contentType:'text/plain;charset='+ settings.encoding, - dataType: 'text', - success: function(data, status) { - parseData(data, settings.mode); - } + return $.ajax({ + url: filename, + async: false, + cache: settings.cache, + contentType:'text/plain;charset='+ settings.encoding, + dataType: 'text', + success: function(data, status) { + parseData(data, settings.mode); + } }); } |