I want to load a JSON file and read the following data
{
"extTitle": {
"message": "test1"
},
"extName":{
"message": "test2"
}
}
This is how I load the data
function loadLocales(){
var userLang = (navigator.language) ?
navigator.language : navigator.userLanguage;
switch(userLang){
default:
$.getJSON("_locales/ne/messages.json", function(data){
return data;
});
break;
}
}
When I try to read with the following function I get an
i18n undefined error
.
function getValue(key){
var i18n = loadLocales();
return i18n[key].message;
}
Any ideas?