Saturday, October 3, 2009

Translate and Detect Languages inside Google Spreadsheet cells with Translation function

Google recently added two new functions to the Google Spreadsheets that will help in translation and language detection.What are those two functions and how do they work?

=GoogleTranslate("Statement to be translated","from language","to language").
=DetectLanguage("Statement from which you want to know the language").


Let us look at the first function GoogleTranslate.
1.It takes 3 arguments.
2.The first parameter contains the statement that needs to be translated.It can even refer to a cell.
3.The second parameter is the two letter language code for the text in first parameter.In other words it is the "source language" code.
4.The third parameter represents the language you want your text to be translated.In other words it is the "destination language" code.
5.The third parameter is optional and if you leave this out ,it will translate the text into the spreadsheet language.
6.You can get the full list of two letter language codes here.

If you want to translate "I Love you" in Simplified Chinese then you will do this as shown below.The first parameter can even refer to a cell containing the text.
The translated text will be shown as displayed below.When you hover your mouse over the translated text, it displays the original text that was translated.
Now let us detect the language of the text in D3.To detect the language use the function DetectLanguage as shown below.
It shows "zh" as the detected language .If I use Traditional Chinese and then use the DetectLanguage function it displays zh-Hant.
You can even use the DetectLanguage function as the 2nd and 3rd parameter inside the function GoogleTranslate as shown below.
The syntax I have used to translate C3 is =GoogleTranslate(C3,DetectLanguage(C3),"zh-TW").The advantage is that instead of hard coding the source language you can use detectLanguage to determine the source language.

About This Blog

This Blog is all about Technology , Web 2.0 ,WebApps.You can also contact the author for advertising on this blog.All the material presented here is the property of author and its reproduction in any form is strictly prohibited.

Contact Us

If you have any suggestions ,queries or comments and want to reach out to me ,then you can reach me here.