How to set on load marathi language using google translator in wordpress?

add this code for your Theme Header (header.php) in head tag:-

<script type="text/javascript">
        function googleTranslateElementInit() {new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'en,mr,hi', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');}
      var url = window.location.href;    
       if (url=='http://demosite.com'){
          url += '#googtrans(en|mr)';
          window.location.href = url;
        }
    </script>

and this line in your body tag:-

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

Leave a Comment