Google Website Translator

coopal's picture

coopal
November 7, 2012
11:59am

I'm trying to install the Google Website Translator on my site.  The Google Website Translator (in theory) should allow visitors to select one of 60 languages in a drop down menu.  After the selection the text should be translated.

After going through the steps to setup the translator, Google gave me these instructions:

  Paste this code onto your website Copy and paste the following code snippets onto every page you want to translate Place this meta tag before the closing </head>


<br />
    I've installed the Meta Module but I'm not sure the best place to include the code. Any suggestions?

Status: Resolved

Comments

Moderator
stacywray November 7, 2012
4:48pm

Hi coopal,

What's the URL to your Gardens site so I can go in and take a look?

I assume there is JavaScript code that you need to add? Please follow our documentation on Adding custom JavaScript code to your site.

You would need to make sure that the JavaScript Libraries module is enabled. Then, in the configuration settings for that module, you can either upload a custom JavaScript Library provided by Google Website Translator as an external file and place that file in the header region of your site; or, you can create a block that you add to the header region and paste the JS code into the HTML tab of the block.

You may need to use a RAW text format when adding the code to a block so that the code renders properly.

Hope this helps!

 

Best regards,

Stacy Wray | Acquia Senior Support Engineer
 

coopal November 7, 2012
5:33pm

Hi Stacy,

Thanks for the quick reply.  My site is www.speakshop.org

You are correct that I need to add Javascript.  Here are the details

  Paste this code onto your website Copy and paste the following code snippets onto every page you want to translate Place this meta tag before the closing </head>   <meta name="google-translate-customization" content="#############################"></meta>  
<br />
  Place this snippet where you'd like to display the Website Translator plugin on your page <div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'en', gaTrack: true, gaId: 'UA-###########'}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

 

 

I replaced the numbers with # that are specific to my site.

Thanks again!

Clay

Moderator
stacywray November 7, 2012
8:26pm

Hi Clay,

I was able to get this to work on my own test site.

First, go to Admin > Configuration > Search and metadata > Meta tags > Global > Override.

Then, paste in the  words "google-translate-customization" into the Description field, and paste in the specific content code for your site into the Keywords field and Save. Because you've put this info in the Global meta tag template, it will apply to all the templates you see under that such as Global: Front page, Content, Taxonomy, etc.

The next step is creating a block with the JS code provided and placing it in the region of your site that you want the actual Language Selector dropdown to appear in, and whether you want that dropdown to appear on every page or just on the <front> page.

Go to Admin > Structure > Blocks > +Add block, and paste in all of the code provided to you in the HTML tab of the block.

Leave the Block Title empty, and add a description like Google Website Translator.

You will need to create a RAW text format, as I linked to above, so that you can select "Raw" from the HTML text format options, i.e. Safe HTML, Full HTML, etc..

Place the block in whatever region you'd like, and set your visibility settings for Pages so that the block either appears on all pages or only on the listed pages you specify. Then, save block and go to your front page and you should see the Language Selector dropdown box like this:

http://screencast.com/t/2Ds5gKfVQ

That should do the trick! Keep us posted...

 

Best regards,

Stacy Wray | Acquia Senior Support Engineer
 

coopal November 8, 2012
5:39pm

Hi Stacy,

Thank you very much.

I followed your instrcuctions and I just installed the Google Website Translator block and it is awesome.  I placed the block at the very bottom of the page until I test it for a little while and then I'll move it to a more visible location but so far it is working perfectly.

Thank you for the quick reply and the great instructions!

Best,

Clay

Moderator
stacywray November 8, 2012
6:23pm

Hi Clay,

You're welcome - glad to help!

Seems like a very handy tool to have on your site.

 

Best regards,

Stacy Wray | Acquia Senior Support Engineer
 

This topic has been closed to further comments.

Feedback