Home > Web Front-end > JS Tutorial > js translates the implementation code of the language configuration of the PHP system through googleAIP_javascript skills

js translates the implementation code of the language configuration of the PHP system through googleAIP_javascript skills

WBOY
Release: 2016-05-16 18:00:43
Original
1564 people have browsed it

Because PHP configuration generally uses data, which is just like the object representation in JS, so it can be like this:

Copy code The code is as follows:



Copy code The code is as follows:

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)
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template