网站接入谷歌翻译实现免费动态翻译网页!

萌新管理 2024-01-23 PM 398℃ 0条

不需要申请谷歌翻译api就可以使用,可以实现动态多语言翻译网站!
但是这种翻译不是很利于SEO排名,直接上代码

`<script>
var language = navigator.language || navigator.userLanguage;
var isChinese = language.toLowerCase().indexOf('zh') > -1;
if (!isChinese) {
var script = document.createElement('script');
window.gtranslateSettings = {"default_language":"zh-CN","native_language_names":true,"detect_browser_language":true,"languages":["zh-CN","en","ja","ko"],"wrapper_selector":".gtranslate_wrapper","flag_size":16,"flag_style":"3d","switcher_text_color":"#f7f7f7","switcher_arrow_color":"#f2f2f2","switcher_border_color":"#161616","switcher_background_color":"#303030","switcher_background_shadow_color":"#474747","switcher_background_hover_color":"#3a3a3a","dropdown_text_color":"#eaeaea","dropdown_hover_color":"#748393","dropdown_background_color":"#474747"};
script.src = 'https://cdn.gtranslate.net/widgets/latest/dwf.js';
var div = document.createElement('div');
div.className = 'gtranslate_wrapper';
document.body.appendChild(script);
document.body.appendChild(div);
}
</script>`

标签: none

非特殊说明,本博所有文章均为博主原创。

评论啦~