There have been a lot of operations in the recent project to translate Chinese into English. I have collected more than 2000 Chinese that have not been translated,
If manual translation is time-consuming, the laziness of programmers inspires the creativity of programmers and implements an automatic translation interface. batch translation is just a flash.
The source code is as follows:
Publicstaticstring GoogleTranslate (string sourceWord, string fromLanguage, string toLanguage)
{
/*
Call: http://ajax.googleapis.com/ajax/services/language/translate? V = 1.0 & langpair = zh-CN | en & q = Chinese are good people
The returned json format is as follows:
{"ResponseData": {"translatedText": "Chinese people are good people" }," responseDetails ": null," responseStatus ": 200 }*/
String serverUrl = @ "http://ajax.googleapis.com/ajax/services/language/translate? V= 1.0 & langpair ="
+ FromLanguage + "|" + toLanguage + "& q =" + HttpUtility. UrlEncode (sourceWord );
WebRequest request = WebRequest. Create (serverUrl );
WebResponse response = request. GetResponse ();
String resJson = new StreamReader (response. GetResponseStream (), Encoding. UTF8). ReadToEnd ();
Int textIndex = resJson. IndexOf ("translatedText") + 17;
Int textLen = resJson. IndexOf ("\" ", textIndex)-textIndex;
Return resJson. Substring (textIndex, textLen );
}
The call is as follows:
TxtMsg. Text = GoogleTranslate (txtMsg. Text, "zh-CN", "en ");
If it is useful, try again.