Because php configuration generally uses data, which is exactly the same as that of objects in js, you can do this:
Copy codeThe Code is as follows: <script type = "text/javascript" src = "http://www.google.com/jsapi"> </script>
Copy codeCode: 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 + "'; <br/> ";
Var div = document. getElementById ("divResult ");
Google. language. translate (oldValue, fromlang, tolang, function (result ){
If (! Result. error ){
Str = "$ strings ['" + name + "'] =" + "'" + result. translation + "'; <br/> ";
}
Div. innerHTML + = str;
});
}
SetTimeout (function (){
For (var name in $ strings ){
Translate (name, $ strings [name]);
}
}, 2000)