我正在使用下面的代码进行谷歌翻译,它工作得很好。问题是那些在中国的人无法访问谷歌翻译下拉菜单,因为 google.translate.com 被屏蔽了。但是 google.translate.cn 没有被屏蔽。我试过在脚本部分简单地使用 google.translate.cn 但是语言下拉菜单都是中文的......
如何引导语言选项中选择中文的用户使用google.translate.cn,世界其他地区的用户使用google.translate.com?
我想我需要使用自定义下拉菜单而不是默认的谷歌下拉菜单?任何人都有如何做到这一点的代码?提前致谢
<Style>
.goog-te-banner-frame.skiptranslate {
display: none !important;
}
body {
top: 0px !important;
font-family: "Segoe UI", "Segoe UI", Segoe, Tahoma, Helvetica, Arial, sans-serif;
font-size: 13px;
font-style: normal;
font-variant-caps: normal;
font-variant-east-asian: normal;
font-variant-ligatures: normal;
font-variant-numeric: normal;
font-weight: 400 ;
}
</Style>
<div id="google_translate_element">
<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'en,ko,ja,id,ms,th,vi,zh-CN,zh-TW', layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL}, 'google_translate_element');
/*
To remove the "powered by google",
uncomment one of the following code blocks.
NB: This breaks Google's Attribution Requirements:
https://developers.google.com/translate/v2/attribution#attribution-and-logos
*/
// Native (but only works in browsers that support query selector)
if(typeof(document.querySelector) == 'function') {
document.querySelector('.goog-logo-link').setAttribute('style', 'display: none');
document.querySelector('.goog-te-gadget').setAttribute('style', 'font-size: 0');
}
// If you have jQuery - works cross-browser - uncomment this
jQuery('.goog-logo-link').css('display', 'none');
jQuery('.goog-te-gadget').css('font-size', '0');
}
</script>
<script type="text/javascript" src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script></div>