Google Page Translator

Today, I added a gadget to my blog so that readers can easily translate my posts into any one of thirty five languages using the Google Translate webpage language translation engine.  You will find it low on the left hand side of this webpage.  From the drop down list, just pick the language you want to convert the current post to and after a short delay a new webpage will appear with the post displayed in the selected language.  Note - you need to have scripts enabled in your browser for the Google gadget to display on this webpage.

Adding this functionality was more challanging than I initially assumed since I wanted to ensure that my posts remained useful to a reader when displayed in a foreign language.  This means that the translation engine needs to be told what words and sections to leave alone as is.  The Google documentation and FAQ for this gadget are unclear about how to do this for things like my display boxes so a round of experimentation was required.  It turns out that you can mark a entire webpage, a word or a section of a webpage as not to be translated using the follows tags.
<!-- use meta element to protect entire webpage -->
<meta name='google' value='notranslate'>
<!-- use span element to protect a word or two -->
<span class='notranslate'>Do not translate these words</span>
<!-- use div element to protect display boxes such this -->
<div class='notranslate'>Do not translate entire section</div>
Now that I have figured out how to protect specific text and code snippets from being translated by the Google translation engine, I plan to go back and modify my previous posts over a period of time to make them more robust for automated language translation.

This will be quite a project as I typically include a number of programming langauge reserved words and code snippets in my posts.  For example, it required over 100 edits to my previous post on Microsoft's Powershell before I was happy that that particular post was suitable for automated language translation.

0 comments:

Post a Comment