Thursday, 13 December 2012

Google Language (translation) APIs asp.net c#

Google Language (translation) APIs asp.net c# 

http://www.dotnetobject.com/Thread-Google-Language-translation-APIs-asp-net-c

The Google Language API Family consists of four powerful tools making it easier for you to communicate with users across the globe:

* Need to translate your website or application into one or more different languages? With Google Translate, you can dynamically translate text between thousands of language pairs.

* Wondering what "have a nice day" looks like written in Hindi? You can use Google Transliterate to transform a given written language into dozens of other scripts.

* Want to type in Hindi, but don't have a Hindi keyboard? With Google Virtual Keyboard, you can provide users with an on-screen keyboard layout native to one of dozens of available language scripts.

* Learning to read Arabic? You can use Google Diacritize to add diacritical marks to text, helping non-native speakers learn how to pronounce these words.


i have created a small asp.net project for translating from one language to another using Google Language apis.

Gapi.Net is a wrapper to implement Google Language api in c#/vb.net


Language API example:

Code:
System.Console.WriteLine("{0}", Translator.Translate("Ciao mondo", Language.Italian, Language.English));

In wrapper developer define enums for all languages. so our first step is to fill dropdownlist with languages for user ease to select the desire language for conversion.
Code:
ddl_langFrom.DataSource = Enum.GetValues(typeof(Language));
ddl_langFrom.DataBind();

because dropdownlist value return a string, but we need Language enum to execute the main Translator.Translate function, we first need to convert string to specified enum.
Code:
Language lngfrm = (Language)Enum.Parse(typeof(Language), ddl_langFrom.SelectedValue);

now simply pass these parameters to Translator.Translate function to get the desire results.

Please check the attached code for complete solution.

Requirements:
.NET Framework 2.0
Complying with Google Terms for using the Search API

[Image: 2rekvo1.png]

Note: if someone want to use this code, then please give a link back to dotnetobject.com.

All credit goes to the developer of gapidotnet




Attached File(s)
.rar  GoogleTrans.rar (Size: 33.26 KB / Downloads: 461)

1 comment:

  1. thank you dotnetcodes, its really nice blog and i like it very much, i am going to share with my friends. hope that they will like it...
    http://www.translation.pk/french-translation.html

    ReplyDelete