summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuabing Zhao <zhaohuabing@gmail.com>2018-06-01 02:29:51 +0000
committerGerrit Code Review <gerrit@onap.org>2018-06-01 02:29:51 +0000
commit5d4b13f67612e8ef44b5bf54bede835e3c575e6e (patch)
treeee9c99c9497fced81e54eb3a5945a8b55ab3f530
parent6f2d499f313a44486e2426f1a8e0767c213c7925 (diff)
parent3be3200bf5b23e966fb20610c2b2930282544d38 (diff)
Merge "Make jquery.i18n fallback to en_US by default"v1.1.02.0.0-ONAPbeijing2.0.0-ONAP
-rw-r--r--discovery-ui/src/main/resources/iui/microservices/js/jquery.i18n/jquery.i18n.properties-1.0.9.js41
1 files changed, 22 insertions, 19 deletions
diff --git a/discovery-ui/src/main/resources/iui/microservices/js/jquery.i18n/jquery.i18n.properties-1.0.9.js b/discovery-ui/src/main/resources/iui/microservices/js/jquery.i18n/jquery.i18n.properties-1.0.9.js
index a4a6a81..1476348 100644
--- a/discovery-ui/src/main/resources/iui/microservices/js/jquery.i18n/jquery.i18n.properties-1.0.9.js
+++ b/discovery-ui/src/main/resources/iui/microservices/js/jquery.i18n/jquery.i18n.properties-1.0.9.js
@@ -80,21 +80,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
@@ -260,15 +263,15 @@ $.i18n.browserLang = function() {
/** Load and parse .properties files */
function loadAndParseFile(filename, settings) {
- $.ajax({
+ return $.ajax({
url: filename,
async: false,
- cache: settings.cache,
+ cache: settings.cache,
contentType:'text/plain;charset='+ settings.encoding,
dataType: 'text',
success: function(data, status) {
- parseData(data, settings.mode);
- }
+ parseData(data, settings.mode);
+ }
});
}