From 901c243ed1bdd5c118af65a79f33a2386543e756 Mon Sep 17 00:00:00 2001 From: Mihaela Stoica Date: Tue, 11 Nov 2014 17:34:50 +0000 Subject: [PATCH] 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. --- ui/scripts/cloudStack.js | 9 +++------ ui/scripts/sharedFunctions.js | 4 +--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/ui/scripts/cloudStack.js b/ui/scripts/cloudStack.js index c5aa89c146d..a76e10169c4 100644 --- a/ui/scripts/cloudStack.js +++ b/ui/scripts/cloudStack.js @@ -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(); diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js index d463381d89e..a7383b7f478 100644 --- a/ui/scripts/sharedFunctions.js +++ b/ui/scripts/sharedFunctions.js @@ -1478,9 +1478,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]";