Auto translating website using Google Translate

后端 未结 2 522
渐次进展
渐次进展 2021-02-11 02:48

I need to find a way to translate a website to the appropriate language as the locale settings on a users machine. So in otherwords someone from Germany visits my site, his loca

相关标签:
2条回答
  • 2021-02-11 03:36

    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.

    0 讨论(0)
  • 2021-02-11 03:43

    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',
    
    0 讨论(0)
提交回复
热议问题