CLOUDSTACK-7645: [UI] Fixed incorrect label issues caused the dictionary split

In some cases the UI does not display the correct text, displaying 'label.xyz' instead of the localized string.
This appears to be due to the dictionary split: entries in dictionary2.jsp are not found because the dictionary has not been extended with dictionary2 as expected.

In this fix:
- Instead of extending the dictionary, we leave it as it is and change the localization function to look in the dictionary first and, if the item is not found there, then look in dictionary2.
- This way we are not depending on the extent() function to be called at the 'right' time; In turn, the localization function will be aware of both dictionaries.
- In the future, when we add another dictionary, we will have to modify this function only.
This commit is contained in:
Mihaela Stoica 2014-11-11 17:34:50 +00:00 committed by Brian Federle
parent f1361796bf
commit d82e556dcd
2 changed files with 4 additions and 9 deletions

View File

@ -407,14 +407,11 @@
// Localization
if (!$.isFunction(cloudStack.localizationFn)) { // i.e., localize is overridden by a plugin/module
cloudStack.localizationFn = function(str) {
return dictionary[str];
// look in dictionary first; if not found, try dictionary2
var localized = dictionary[str];
return localized ? localized : dictionary2[str];
};
}
//added for dictionary split up
if (dictionary != undefined && dictionary2 != undefined) {
$.extend(dictionary,dictionary2);
}
// Localize validation messages
cloudStack.localizeValidatorMessages();

View File

@ -1454,9 +1454,7 @@ var processPropertiesInImagestoreObject = function(jsonObj) {
}
return vmName;
}
var dictionary = {}, dictionary2 = {}; //for globalization
var timezoneMap = new Object();
timezoneMap["Etc/GMT+12"] = "Etc/GMT+12 [GMT-12:00]";
timezoneMap["Etc/GMT+11"] = "Etc/GMT+11 [GMT-11:00]";