Auto translating website using Google Translate

[亡魂溺海] 提交于 2019-12-03 09:54:37

I know that when I visit a site in another language using Google Chrome, it says "This site appears to be in [Drop Down With Languages]. Do you want Google to translate it?" They might have an api that can do that per page.

However, if your site is at all professional, you should get someone to actually translate your site for you, as occasionally Google translate fails in embarrassing ways.

Use Follwing code in your head tag

<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en',
layout: google.translate.TranslateElement.InlineLayout.SIMPLE
}, 'google_translate_element');
}
</script><script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

display laguage dropdown where you want to display it

<div id="google_translate_element"></div>

If use only some languages translate than use

pageLanguage: 'en',
includedLanguages: 'pt,ar',
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!