[jQuery] JSON data issue in IE | Language Translation
Hi All,
Hope, you all would be doing well.
I am trying to create a language translation utility using jQuery for
some specific words only, seems working fine in Firefox but don’t do
well in IE 6/7.
Given is the JSON file, where I map headings which needs to be
translated in French.
JSON Data:
{
"download" : "télécharger",
"categories" : "sujets d'actualité",
"recent_comments" : "mais que l'histoire de l'",
"recent posts" : "Messages Récents",
"also worthy" : "aussi digne",
"archieves" : "archives",
}
I am able to load my JSON file successfully using $.getJSON(), it
translates in FF but does not do the same in IE 6/7.
jQuery Method:
function loadJSON(){
$.getJSON("json/data_ca_fr.json", function(json){
$(".json_trans").each(function(i){ //getting all the headings to
translate
switch($(".json_trans")[i].innerHTML) {
case "Download": // Start here if $(".json_trans")[i].innerHTML
== "download"
$(".json_trans")[i].innerHTML = json.download; break;// Stop
here
case "Categories": // Start here if $(".json_trans")[i].innerHTML
== "download"
$(".json_trans")[i].innerHTML = json.categories;
break;// Stop here
default
break;
}
})
});
}
I am just comparing English words in the page through innerHTML
because jQuery html() return the first array index only , defined
span tag with .json_trans class for picking up all the required spans
and do the translation.
I know, it’s not the robust way to do the language translation but
does require for client and it’s not AJAX at all, just calling the
json file on dom ready.
Any quick pointer/ suggestion should be appreciated.
Thanks for your time
Mohammed Arif
http://www.mohammedarif.com