用GOOGLE轻松制作自己的多国语言网站~~(转)

用了这么久GOOGLE才知道原来他可以翻译网站的。

下面给出一段代码

CODE:[Copy to clipboard]
1<script language="JavaScript">   
2document.write('<A href="http://translate.google.com/translate?sl=en&hl=de&u=' + document.URL+ '"><IMG width=22 height=12 alt="Translate this page to German" src="img/de.gif" border="0"></A> ');   
3document.write('<A href="http://translate.google.com/translate?sl=en&hl=fr&u=' + document.URL+ '"><IMG width=22 height=12 alt="Translate this page to French" src="img/fr.gif" border="0"></A> ');   
4document.write('<A href="http://translate.google.com/translate?sl=en&hl=it&u=' + document.URL+ '"><IMG width=22 height=12 alt="Translate this page to Italian" src="img/it.gif" border="0"></A> ');   
5document.write('<A href="http://translate.google.com/translate?sl=en&hl=es&u=' + document.URL+ '"><IMG width=22 height=12 alt="Translate this page to Spanish" src="img/es.gif" border="0"></A> ');   
6document.write('<A href="http://translate.google.com/translate?sl=en&hl=pt&u=' + document.URL+ '"><IMG width=22 height=12 alt="Translate this page to Portuguese" src="img/pt.gif" border="0"></A> ');   
7document.write('<A href="http://translate.google.com/translate?sl=en&hl=ru&u=' + document.URL+ '"><IMG width=22 height=12 alt="Translate this page to Russian" src="img/ru.gif" border="0"></A> ');   
8</script>

图片包下载: http://free1.e-168.cn/~sf/img.zip
在插入代码的网页的同级目录下建立img目录将图片复制进去即可~

只要将以上代码插入你的英文网站就可以轻松实现整站翻译的效果,下面来对这个翻译的连接注释一下!

CODE:[Copy to clipboard]
http://translate.google.com/translate?[color=Red]sl=en[/color]&amp;[color=Blue]hl=de[/color]&amp;u=[color=Green]' + document.URL+ '[/color]

红字sl=en :你网站的当前语言
篮字hl=de :你要翻译的语种
绿字' + document.URL+ ' :这里表示读取当前连接,你也可以修改成自己的想要翻译的地址

这个地址表示把当前的英文网站翻译成德语网站

世界上虽然很多国家但是常用的语言也就那么几个,因为大多被殖民过了,所以我们不要翻译很多。下面我把常用的各国语言的在GOOGLE上的翻译连接上的缩写给大家罗列一些。

zh-CN简体中文,zh-TW繁体中文,en英文,fr法国语,de德语,pt葡萄牙语,it意大利语,es西班牙语,ru俄语

这些就是基本长用的了如果你想翻译更多语言可以到http://www.google.com/language_tools?hl=zh-CN 去查一下各国语言的google缩写。

注意: 我自己实验中,把中文翻译成其他语言或者把其他语言翻译成中文都不好使,几乎都是乱码,所以这个可能只适用于E文网站。

下面是一个成品演示。
http://www.proxycn.net

付送一个代理中国多国语言的演示版,没有E文叶子的可以自己下载一个玩,里面的IMG是国旗图片
http://free1.e-168.cn/~sf/im286.zip

Published At
Categories with Web编程
Tagged with
comments powered by Disqus