Language Translation

Google Translate

Google Translate

You can use the Google Translate service to add a language translation option to your WordPress website.

Use this Google wizard to create the code snippet: Create Translate Code Snippet

Or if you just want to use the default Google Translate widget, you can use this snippet:

<div id="google_translate_element"></div><script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en'
}, 'google_translate_element');
}
</script><script
src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

Sidebar or Masthead

To place your Translator in your sidebar, just drag a text widget into a sidebar and paste the code snippet into it.

If you want your Translator to appear in your masthead, you can use Dashboard, Appearance, Site Design and paste your code snippet in to the Custom Header Text field (within the Header section).

To place the Translator object using absolute positioning you can use this Custom CSS rule:

/* Google Translate */
div#google_translate_element {width: 190px; position: absolute; top: 0; left:0;}

WordPress Multisite

If your website is based on WordPress Multisite (and most OM4 sites are set up this way), you’ll need to ask for your user account to be given authorisation to paste Javascript code snippets.

notranslate

As per this article, if you wish to ensure that certain parts of your page aren’t translated (for example code samples or quotes), you can do so by adding a notranslate class. For example:


This content will be translated.
<div class="notranslate">This content won't be translated</div>
This content will also be translated.