Using Google translation API in C# stand alone application

316 views
Skip to first unread message

jishad

unread,
Mar 10, 2009, 11:51:12 AM3/10/09
to Google AJAX APIs
Hi,
I am using Google API to translate the string, but some times it will
not translate properly. Recently i found a new issue it is not able to
download the data. it is showing the error: "The remote server
returned an error: (503) Server Unavailable".

One more point is that it is a stand alone application (not a web
application) in c# Windows.
this is the code i have written:

string url = String.Format("http://www.google.com/translate_t?
hl=en&ie=UTF8&text={0}&langpair={1}", "apple", "en|de");

WebClient webClient = new WebClient();
webClient.Encoding = System.Text.Encoding.UTF8;
// Get Default Proxy
IWebProxy proxy = WebRequest.GetSystemWebProxy();

proxy = new WebProxy(sProxyAddr);
proxy.Credentials = new NetworkCredential(sUserName, sPasswd);
webClient.Proxy = proxy;
string result = webClient.DownloadString(url);

please give a solution to this probelm.

thanks
Jishad

Ben Lisbakken

unread,
Mar 10, 2009, 6:05:10 PM3/10/09
to Google-AJAX...@googlegroups.com
Jishad --

Please be sure to URL encode your request.  Specifically, you cannot put en|de as your language pair.  It should be en%7Cde.

Let me know if this solves the problem.

-Ben
Reply all
Reply to author
Forward
0 new messages