Use Google Translate for FREE in your Apps

作者: admin 分类: 未分类 发布时间: 2013-06-19 13:51 ė1,986 浏览数 6没有评论

The Google Translate API  are not free.We built a HACK which allows us to use it for FREE!!

Note:This hack is a result of one night work done for submission of some college project and has been used only for 2 days for a max of 10 queries. It is based on pure observance and is not intended to cause any harm. The author is in no way responsible for the actions of the reader.

TL;DR: if you are looking for the code that allows you to use Google Translate in your app for FREE then go to the end of this post. :)

This is how we went about building it:

If you go to and try to translate a sentence for example:(just click on the image for better view)ggltranslate
Then for some one who has basic understanding of web might think that sending a request  of the form “<source language code>/<target language code>/<sentence to be translated>” will get them the results , but this does not workout.

So we go a little bit deeper in our exploration, we use one of our favorite development tool “Firebug” to examine how the page responds to our actions. So now our plan is to observe the AJAX requests that the page makes. For observing these we Switch on our firebug and go to the ‘net’ tab:

In case it says its off then just switch it on and reload the page.

Now we try to change the text to anything we want and observe the requests being made. So we get something of this kind.

So these are the requests sent during our text change, now we need to figure out which one of these are useful for us. For this we checkout the requests going to and for which the status is ‘OK’, and this is what we observe:


TAdAA…!!! we got it !!
This was the url where the request was sent:

Now most of the work is done , the only thing that remains is to generalize the request url and extract the desired ans from the response which is pretty simple.

This is a small C# code snippet that does everything for you:

string text="i am loving it";
string url = "" + text.Replace(" ", "%20") + "&hl=en&sl=en&tl=ta&ie=UTF-8&oe=UTF-8&multires=1&otf=2&ssel=0&tsel=0&sc=1";
WebRequest wr = WebRequest.Create(url);
Stream resp= wr.GetResponse().GetResponseStream();
StreamReader respReader = new StreamReader(resp);
string s = "",ans=respReader.ReadToEnd();
string[] arr=ans.Split(',');
s = arr[0];
return s;// this is the translated text!!

Just change the variable ‘text’ to the sentence you want to translate. For translation to the language of your choice just look up the language code with the help of firebug and substitute it in place of ‘ta’ in ‘tl=ta’ in the request url.
Have Fun!!!

只回答业务咨询点击这里给我发消息 点击这里给我发消息


本文出自 王牌软件,转载时请注明出处及相应链接。




电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">