Because PHP configuration generally uses data, which is just like the object representation in JS, so it can be like this:
var $strings={};
$strings['hide ']='hide';
$strings['show']='show';
google.load("language", "1");
function translate(name,oldValue){
var fromlang = "en";
var tolang ="zh-CN";
var str="$strings['" name "']=" "'" oldValue "';
";
var div=document.getElementById ("divResult");
google.language.translate(oldValue, fromlang, tolang, function(result) {
if (!result.error) {
str="$strings['" name "']=" "'" result.translation "';
";
}
div.innerHTML =str;
});
}
setTimeout(function(){
for(var name in $strings){
translate(name,$strings[name]);
}
} ,2000)