Tejas Rana

Integration of Google Translate in any website

Do you need your website in multilingual but don’t want to repopulate content in multiple language. In that case you can use Google API to make your website multilingual.
First of all decide the area where you want to add language selector.
In that place you have to add this DIV section with ID so that Script find that block and append language dropdown.

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

now add JS library for translation.

<script src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

Its up to you where you want to add this library either in head section or in footer. but I recommend you to place it in footer so that you web page load quickly and after that it call 3rd party library.
now after this library call its function so that it start working. For that we have to use this JS snippt

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

That’s all.. now you will be able to see drop down on that place where you call that DIV section.

Exit mobile version