Accessibility Tool

Installing Google Translate

Default code to add Google Translate with ALL languages to a website:

Add these scripts to the <HTMLhead> of the template:

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

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

Code for sites or pages with content in multiple languages (IE: pages with non-discrimination tagline translations):

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

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

Once you have your scripts in place, add the div below wherever you want Google Translate to appear on the website (template, page layout, content portlet etc.)

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

The Google Translate widget will look like this on the website:

Specifying Languages

You will use the code below in the <HTMLhead> section of the template. The difference in this code is it has the "includedLanguages" section. You will edit it, adding in the language code(s) for the countries requested by the client.

<script type="text/javascript"> function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'pa,ur,hi', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element'); } </script>

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

Check Google's Language Support documentation for language codes for every country.

2024 © All Rights Reserved | Website Design By: Televox | Login