Monday, January 25, 2010

Add Google Translate Tool To Your Webpage Or Blog


1. Google Translate Element
Go to http://www.google.com/webelements/translate/. With a little configuration, you can get a snippet of javascript code to put on your web page or blog. By choosing "Display" as "Always", you get a menu of "Select Language"; by choosing "Display" as "Automatic", you can invoke the Google Translate automatically.

If you just want to specify a subset of destination languages, you can go to http://translate.google.com/translate_tools to setup the code. After you select some specific languages, a parameter "includedLanguages" is added to the Google TranslateElement.

2. Play with Google Translate URL
If you just want to translate your web page or blog into one specific language, there is no point in adding a menu. You can just add a button. For example, if you want to add a button to let the readers translate your web page from English to French, you can add this snippet of code:
<form action="http://www.google.com/translate" onsubmit="this.u.value=window.location.href" method="GET">
<input value="en" name="sl" type="hidden"/>
<input value="fr" name="tl" type="hidden"/>
<input value="" name="u" type="hidden"/>
<input value="FRANÇAIS" type="submit"/>
</form>

If you are using Blogger.com, you can add a Page Element of "HTML/JavaScript" with the code above and you get the Google Translate tool on your blog. It is very convenient.

No comments:

 
Get This <