How to add google translator to a website.

How to add google translator to a website.

add this script tag to the bottom of the body of your html

<script type="text/javascript"
    src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

Now add this javascript code after this added script tag

<script type="text/javascript">
    function googleTranslateElementInit() {
      new google.translate.TranslateElement({
        pageLanguage: 'en'
      }, 'google_translate_element');
    }
  </script>

Now add this div any where on page where you want to show the translator drop down menu

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

Leave a Comment

Scroll to Top