If you ever use google translation of the text - you can build it. In this article I illustrate how to build your translated text functions like text translation feature that google offers. DEMO
We will use the WebService provided by msdn.microsoft.com. You perform the following steps Step 1: Register AppID. To use the WebService you need a Hotmail account to login. After logging in you create a link http://msdn.microsoft.com/en-us/library/ff512386.aspx AppID. If you are afraid to sign up you can use the AppID that I have available is registered: 3CDF850957DBFFCCE5E0E313B63F38332A01F755. Reality when you already have AppID then you can use the following link to translate the data you need http://api.microsofttranslator.com/v2/Http.svc/Translate?appId = "+ appId +" & text = "+ textvalue +" & from = "+ from +" & to = "+ to; of which is the code you appID registered, textvalue is paragraph text to be translated, from the code language to be translated, to the language code you want to translate. So we will build a form to convert the link with the events on the form. Step 2: Building Form You design the interface from the following:

Code that interface as follows:
<table style="width: 600px;">
<tr>
<td>
Từ: <asp:DropDownList ID="ddlFrom" runat="server">
<asp:ListItem Text="VietNam" Value="vi" Selected="True" />
<asp:ListItem Text="English" Value="en" />
<asp:ListItem Text="Polish" Value="pl" />
<asp:ListItem Text="German" Value="de" />
<asp:ListItem Text="French" Value="fr" />
<asp:ListItem Text="Swedish" Value="sv" />
<asp:ListItem Text="Chinese Simplified" Value="zh-cn" />
</asp:DropDownList>
Sang: <asp:DropDownList ID="ddlTo" runat="server">
<asp:ListItem Text="VietNam" Value="vi" />
<asp:ListItem Text="English" Value="en" Selected="True" />
<asp:ListItem Text="Polish" Value="pl" />
<asp:ListItem Text="German" Value="de" />
<asp:ListItem Text="French" Value="fr" />
<asp:ListItem Text="Swedish" Value="sv" />
<asp:ListItem Text="Chinese Simplified" Value="zh-cn" />
</asp:DropDownList>
<asp:Button ID="btnTranslate" runat="server" onclick="btnTranslate_Click" Width="80px" Text="Dịch" />
</td>
</tr>
<tr>
<td >
<asp:TextBox ID="txtValue" runat="server" Height="80px" TextMode="MultiLine"
Width="600px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Literal ID="ltTranslatetxt" runat="server"></asp:Literal>
</td>
</tr>
</table>
Step 3: Write code: Translate function you write and use it in the button's click event as follows
public void Translate(string textvalue, string from, string to)
{
string appId = "3CDF850957DBFFCCE5E0E313B63F38332A01F755";
string uri = "http://api.microsofttranslator.com/v2/Http.svc/Translate?appId=" + appId + "&text=" + textvalue + "&from=" + from + "&to=" + to;
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
WebResponse response = null;
try
{
response = httpWebRequest.GetResponse();
using (Stream stream = response.GetResponseStream())
{
System.Runtime.Serialization.DataContractSerializer dcs = new System.Runtime.Serialization.DataContractSerializer(Type.GetType("System.String"));
string translation = (string)dcs.ReadObject(stream);
ltTranslatetxt.Text = "<b>Bản dịch: </b><br>" + translation + "";
}
}
catch (WebException e)
{
txtValue.Text = "Failed to translate";
}
finally
{
if (response != null)
{
response.Close();
response = null;
}
}
}
protected void btnTranslate_Click(object sender, EventArgs e)
{
Translate(txtValue.Text, ddlFrom.SelectedItem.Value.ToString(), ddlTo.SelectedItem.Value.ToString());
}
You may notice declaring the library:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
Trong code trên tôi chỉ minh họa mã ngỗn ngữ của mấy nước, nếu bạn cần bạn có thể lấy mã ngôn ngữ của các quốc gia khác trong danh sách sau đây:
'ALBANIAN' : 'sq',
'ARMENIAN' : 'hy',
'BASQUE' : 'eu',
'BURMESE' : 'my',
'CATALAN' : 'ca',
'CHEROKEE' : 'chr',
'CHINESE' : 'zh',
'CHINESE_SIMPLIFIED' : 'zh-CN',
'CHINESE_TRADITIONAL' : 'zh-TW',
'CORSICAN' : 'co',
'CROATIAN' : 'hr',
'CZECH' : 'cs',
'DANISH' : 'da',
'DHIVEHI' : 'dv',
'DUTCH': 'nl',
'ENGLISH' : 'en',
'ESPERANTO' : 'eo',
'ESTONIAN' : 'et',
'FAROESE' : 'fo',
'FILIPINO' : 'tl',
'FINNISH' : 'fi',
'FRENCH' : 'fr',
'FRISIAN' : 'fy',
'GALICIAN' : 'gl',
'GEORGIAN' : 'ka',
'GERMAN' : 'de',
'GREEK' : 'el',
'GUJARATI' : 'gu',
'HAITIAN_CREOLE' : 'ht',
'HEBREW' : 'iw',
'HINDI' : 'hi',
'HUNGARIAN' : 'hu',
'ICELANDIC' : 'is',
'INDONESIAN' : 'id',
'INUKTITUT' : 'iu',
'IRISH' : 'ga',
'ITALIAN' : 'it',
'JAPANESE' : 'ja',
'JAVANESE' : 'jw',
'KANNADA' : 'kn',
'KAZAKH' : 'kk',
'KHMER' : 'km',
'KOREAN' : 'ko',
'KURDISH': 'ku',
'KYRGYZ': 'ky',
'LAO' : 'lo',
'LATIN' : 'la',
'LATVIAN' : 'lv',
'LITHUANIAN' : 'lt',
'LUXEMBOURGISH' : 'lb',
'MACEDONIAN' : 'mk',
'MALAY' : 'ms',
'MALAYALAM' : 'ml',
'MALTESE' : 'mt',
'MAORI' : 'mi',
'MARATHI' : 'mr',
'MONGOLIAN' : 'mn',
'NEPALI' : 'ne',
'NORWEGIAN' : 'no',
'OCCITAN' : 'oc',
'ORIYA' : 'or',
'PASHTO' : 'ps',
'PERSIAN' : 'fa',
'POLISH' : 'pl',
'PORTUGUESE' : 'pt',
'PORTUGUESE_PORTUGAL' : 'pt-PT',
'PUNJABI' : 'pa',
'QUECHUA' : 'qu',
'ROMANIAN' : 'ro',
'RUSSIAN' : 'ru',
'SANSKRIT' : 'sa',
'SCOTS_GAELIC' : 'gd',
'SERBIAN' : 'sr',
'SINDHI' : 'sd',
'SINHALESE' : 'si',
'SLOVAK' : 'sk',
'SLOVENIAN' : 'sl',
'SPANISH' : 'es',
'SUNDANESE' : 'su',
'SWAHILI' : 'sw',
'SWEDISH' : 'sv',
'SYRIAC' : 'syr',
'TAJIK' : 'tg',
'TAMIL' : 'ta',
'TATAR' : 'tt',
'TELUGU' : 'te',
'THAI' : 'th',
'TIBETAN' : 'bo',
'TONGA' : 'to',
'TURKISH' : 'tr',
'UKRAINIAN' : 'uk',
'URDU' : 'ur',
'UZBEK' : 'uz',
'UIGHUR' : 'ug',
'VIETNAMESE' : 'vi',
'WELSH' : 'cy',
'YIDDISH' : 'yi',
'YORUBA' : 'yo',
'UNKNOWN' : ''