利用谷歌翻译接口实现网站多语言切换
日期:2018-07-08
js利用google翻译接口把网页翻译成各国语言,代码如下
<?php $language_trans_array = array( array('value' =>'sl=&tl=de', 'text' =>'German',), array('value' =>'sl=&tl=es', 'text' =>'Spanish',), array('value' =>'sl=&tl=tl', 'text' =>'Arabic',), //阿拉伯语 array('value' =>'sl=&tl=fr', 'text' =>'French',), array('value' =>'sl=&tl=it', 'text' =>'italiano',), array('value' =>'sl=&tl=ja', 'text' =>'Japanese',), array('value' =>'sl=&tl=ko', 'text' =>'Korean',), //韩语 array('value' =>'sl=&tl=pt', 'text' =>'Portuguese',), //葡萄牙语( array('value' =>'sl=&tl=zh-cn', 'text' =>'Chinese',), array('value' =>'sl=&tl=ru', 'text' =>'Russian',), //俄罗斯语 array('value' =>'sl=&tl=nl', 'text' =>'Dutch',), //荷兰语 array('value' =>'sl=&tl=da', 'text' =>'Denmark',), //丹麦语 ); ?>
<form method="get" action="" width="155" name="search_category"> <input type="hidden" value="9c1607517d3b8fe4f1c1e053d9b5c3c1" name="securityToken"> <select class="top_serach" onchange="javascript: void(window.open('http://translate.google.com/translate?' +this.value +'&u=https://www.ecshop.cx', 'change', 'resizable,scrollbars,status'))" name="search_category_id" rel="dropdown"> <option selected="selected" value="sl=en&tl=de">english</option> <?php foreach($language_trans_array as $trans) { ?> <option value="<?php echo $trans['value'];?>"> <?php echo $trans['text'];?> </option> <?php } ?> </select> </form>
本文原创地址:https://www.ecshopok.com/article-391.html
版权所有 © 转载时必须以链接形式注明出处!
觉得本文对您有用,想收藏下来!方法很简单:请点击-〉
我们一直坚持白天工作、晚上熬夜更新资源,付出了巨大的精力和时间,其中的辛酸难以言述。
暂无评论,来发表一个吧