js通过googleAIP翻译PHP系统的语言配置的实现代码
因为php的配置一般用数据,正好和js里的对象表示一般,所以可以这样:
代码如下:
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
代码如下:
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)
相关推荐
88274956 2020-11-03
runner 2020-09-01
梦的天空 2020-08-25
移动开发与培训 2020-08-16
ReunionIsland 2020-08-16
lyqdanang 2020-08-16
MyNameIsXiaoLai 2020-07-08
星辰的笔记 2020-07-04
csstpeixun 2020-06-28
letheashura 2020-06-26
liaoxuewu 2020-06-26
sunzhihaofuture 2020-06-21
FEvivi 2020-06-16
坚持着执着 2020-06-16
waterv 2020-06-14
xiaoge00 2020-06-14
firejq 2020-06-14
firstboy0 2020-06-14
e度空间 2020-06-12
zhongweinan 2020-06-10