Crossroad >> Code >> Article
Google
 
Web akhilesh.in
Home
  Articles
  PalmOS



How to localize your Web Site for free

How to localize your web site for International visitors?
How to translate your page to different languages?
How to make your site accessible in all the languages on continuous basis?
And all this without making much of hard work and almost free!

Answer is Google Language Tool.

I have been using this tool for reading content written in non English language for past few years, and day by day it is getting better and better.

This feature uses google language tool to translate any web page that is present on the Internet to other language. The exact feature set and accuracy lies with the Google's language conversion tool.

See the tool and its features and limitations at
http://www.google.co.in/language_tools?hl=en

The user gets this capability automatically if he/she has installed Google Tool Bar. Right click Menu Context menu gives the option for conversion into the default language.

The list of languages supported by Google are

English
German
Spanish
French
Italian
Portuguese
Japanese
Korean
Chinese (Simplified)

Conversion that are performed by this date (February 2006) are

English to German
English to Spanish
English to French
English to Italian
English to Portuguese
English to Japanese
English to Korean
English to Chinese (Simplified)

German to English
German to French

Spanish to English

French to English
French to German

Italian to English
Portuguese to English
Japanese to English
Korean to English
Chinese (Simplified) to English

 

 


 

Now how to perform the Conversion from your site?

Basically Google provides an simple interface on the language tool's page

You simply provide the URL to translate and Google will do it for you. The output you get is something like this:

 

This was simple, now how do you trigger the same from your site?

If you look at the address bar after it was converted. It will be something like this

http://translate.google.com/translate?u=http%3A%2F%2Fwww.akhilesh.in%2Fme&langpair=en%7Cfr&hl=en&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_tools


Breaking it up

Tool's URL
http://translate.google.com/translate

URL to Translate
u=http%3A%2F%2Fwww.akhilesh.in%2Fme

Language Pair (Convert From and Convert To)
langpair=en%7Cfr

%7C is the divider between the two language. First one is from and second is to.
In this case it is en (for English) and fr (for French)

All the language codes are given below

Code Language
en English
es Spanish
fr French
it Italian
pt Portuguese
ja Japanese
ko Korean
zh-CN Chinese (Simplified)

Rest are encoding and other information.


To translate any URL you need replace the parameter u= with the site to translate. And the appropriate language pair for the conversion.

It can be Simply put in as a script for convenient calling, as given below:

<SCRIPT language="JavaScript">

<!-- Copyright akhilesh.in

var u1="http://translate.google.com/translate?u=";
var u2="&langpair=";
var u3="%7C";
var u4="&hl=en&safe=off&ie=UTF-8&oe=UTF-8&prev=/language_tools";

var vfrom=0;
var vto=0;


var lang= new Array(8);

lang[0]="en"; //English
lang[1]="es"; //Spanish
lang[2]="fr"; //French
lang[3]="it"; //Italian
lang[4]="pt"; //Portuguese
lang[5]="ja"; //Japanese
lang[6]="ko"; //Korean
lang[7]="zh-CN"; //Chinese (Simplified)


function translate(vfrom, vto)
{
location.href=u1+document.location.href+u2+lang[vfrom]+u3+lang[vto]+u4;
}

-->

</SCRIPT>

 

Using the script is easy. Just call the function translate() with first parameter as from language and second as to. For simplicity and convenience the language codes are stored in array and referenced by number as given.

So to say translate from English to Chinese, the link will look like this:

 

<a href="javascript:translate(0, 7);">English -> Chinese (Simplified)</a>

 

A complete example is given below, that you can copy paste and use at your site.

<SCRIPT language="JavaScript">

<!-- Copyright akhilesh.in

var u1="http://translate.google.com/translate?u=";
var u2="&langpair=";
var u3="%7C";
var u4="&hl=en&safe=off&ie=UTF-8&oe=UTF-8&prev=/language_tools";

var vfrom=0;
var vto=0;


var lang= new Array(8);

lang[0]="en"; //English
lang[1]="es"; //Spanish
lang[2]="fr"; //French
lang[3]="it"; //Italian
lang[4]="pt"; //Portuguese
lang[5]="ja"; //Japanese
lang[6]="ko"; //Korean
lang[7]="zh-CN"; //Chinese (Simplified)


function translate(vfrom, vto)
{
location.href=u1+document.location.href+u2+lang[vfrom]+u3+lang[vto]+u4;
}

-->

</SCRIPT>

Translate This Page
<br>


<a href="javascript:translate(0, 1);">English -> Spanish</a><br>
<a href="javascript:translate(0, 2);">English -> French</a><br>
<a href="javascript:translate(0, 3);">English -> Italian</a><br>
<a href="javascript:translate(0, 4);">English -> Portuguese</a><br>
<a href="javascript:translate(0, 5);">English -> Japanese</a><br>
<a href="javascript:translate(0, 6);">English -> Korean</a><br>
<a href="javascript:translate(0, 7);">English -> Chinese (Simplified)</a><br>

 

Example Use

Translate This Page

English -> Spanish
English -> French
English -> Italian
English -> Portuguese
English -> Japanese
English -> Korean
English -> Chinese (Simplified)

 

Last Updated 12th Febryary 2005

 


Crossroad | About Me | Science | Life | Code | Contact | Site Map | Search
Copyright © 2006 - 2009 akhilesh.in