0

我正在使用带有国家标志的谷歌语言选择器,方法是在 wordpress 的模板文件中使用以下代码。

           <!-- Add English to Chinese (Simplified) BETA -->

           <a target="_blank" rel="nofollow" onclick="window.open('http://www.google.com/translate?u='+encodeURIComponent(location.href)+'&langpair=en%7Czh-CN&hl=en&ie=UTF8'); return false;" title="Google-Translate-Chinese (Simplified) BETA"><img border="0" style="cursor:pointer; cursor:hand;" width="19" alt="Google-Translate-Chinese (Simplified) BETA" src="https://sites.google.com/site/translationflags/images/_chinese_s.png" height="19" title="Google-Translate-Chinese (Simplified) BETA"/></a>

           <!-- END English to Chinese (Simplified) BETA-->



         <!-- Add English to French -->

             <a target="_blank" rel="nofollow" onclick="window.open('http://www.google.com/translate?u='+encodeURIComponent(location.href)+'&langpair=en%7Cfr&hl=en&ie=UTF8'); return false;" title="Google-Translate-English to French "><img border="0" style="cursor:pointer; cursor:hand;" width="19" alt="Google-Translate-English to French " src="https://sites.google.com/site/translationflags/images/_french_s.png" height="19" title="Google-Translate-English to French "/></a>
             ...

             ...

当我们点击网页中的标志时,它会被重定向到其他页面(谷歌的翻译页面)。并且页面被翻译成其他语言。但我希望它不应该被重定向到其他页面,而是应该在同一页面上翻译,就像使用带有下拉选项的简单谷歌翻译代码一样。请帮我!!!

4

1 回答 1

1

我想你只需要:-

<div id="google_translate_element" style="float:left; padding-left:15px">
</div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en',  multilanguagePage: true,
layout: google.translate.TranslateElement.FloatPosition.BOTTOM_RIGHT},     'google_translate_element');
}
</script> 
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?    cb=googleTranslateElementInit"></script>

试试这个

于 2013-04-15T07:48:06.230 回答