Hello All,
I am facing issue about getting a return value from the below function; Here i have added two alerts, the first alert(value + "11111111111111") is getting the correct value but the second alert is showing null. Not sure why.
function GetTranslatedValue(key)
{
var value;
var locale_file_path;
var lang = user_PreferenceLanguage.split('-');
locale_file_path ="TestFoler/i18n/locale-"+lang[0]+".json";
var en_JSON;
var translated_JSON;
loadJSON("TestFoler/i18n/locale-en.json", function(response){
en_JSON = JSON.parse(response);
});
loadJSON(locale_file_path, function(response){
translated_JSON = JSON.parse(response);
value = translated_JSON[key] != null && translated_JSON[key] != "" ? translated_JSON[key] : en_JSON[key];
alert(value + "11111111111111"); //Getting correct value here
});
alert(value + "2222222222222"); //Getting null value. Not sure why
return value;
}