8

I hear that the Translate API will be charged for, but what exactly prevents us form using the free Google Translate service here for free ? Otherwise put, what are the limitations of the free service?

Alex Martelli
  • 854,459
  • 170
  • 1,222
  • 1,395
kellogs
  • 2,837
  • 3
  • 38
  • 51

3 Answers3

19

According to the link below, nothing prevents you.

https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=es&dt=t&q=Hello

Set your requests content-type to application/json and it fixes the weird formatting, I found the uri pattern after bashing around the google websites for a while.

I wouldn't recommend translating the bible with it but I've done ~10k words this week without an issue.

If anyone finds another working client value I'd love to know.

8eecf0d2
  • 1,569
  • 1
  • 13
  • 23
  • 5
    You should also specify your encodings properly otherwise accents will be messed up. `&ie=UTF-8&oe=UTF-8` should be included in your URL and don't forget to set the `WebClient` to `Encoding = Encoding.UTF8` – Slate May 07 '17 at 01:01
  • In 2019, I have been (temporarily ≈ 1-2h) blocked after no more than about 100 requests. Changing public IP works (for this I had to restart my modem). – MagTun Aug 07 '19 at 12:42
  • 2
    @MagTun thanks for the feedback, I've just tried this method again myself and was blocked after ~100 sequential requests in under a minute. During that time a HTML page with a ReCaptcha was being returned instead of the expected response. The requests began succeeding again after several minutes of no requests and without submitting the ReCaptcha. – 8eecf0d2 Aug 27 '19 at 21:40
  • 1
    I have asked a question to better understand the difference between the different Google API but it hasn't attracted a lot of attention: https://stackoverflow.com/questions/57397073/difference-between-the-google-translate-api – MagTun Aug 28 '19 at 11:19
  • anyone has any idea how to prevent google not translating a part of a string i tried it with notranslate class and and translate=no but dosent works. like here `

    You can translate the not this part this by selecting a language in the select box.

    `
    –  Sep 08 '20 at 08:31
4

There is nothing stopping you from using the Google Translate site, other than accessibility. The public API gives you a much tighter integration than, say, trying to embed Google Translate into your site via a frame.

ean5533
  • 8,884
  • 3
  • 40
  • 64
  • so what is stopping me from manually crafting some HTTP packets and sending them to Google Translate servers from any C++ app ? The results would be cleanly displayed in some custom UI.. – kellogs Nov 10 '11 at 20:44
  • 3
    Nothing, go for it. Just don't be surprised when Google quickly notices a pattern and blocks you. You surely aren't the first person to try it. The question you need to ask yourself: is the time you're going to spend hacking around their site _really_ worth less than the $20 you could pay to use their API? Unless you can make the whole thing work in half an hour of work, I'd say you're cutting yourself short. – ean5533 Nov 10 '11 at 21:03
  • how do they block me :D ? the IP varries, there is no account needed to use the service.. what is "the pattern" ? – kellogs Nov 10 '11 at 21:14
  • 1
    The headers on your packets, for a start. I could think of a handful of ways to detect if someone was abusing my free service, and I'll bet that the guys at Google are a hell of a lot smarter than me. Again, why not just pay the money? – ean5533 Nov 10 '11 at 21:22
  • no way they could ban my app judging by just the headers.. wth! No, I am not going to attempt to abuse it, only to use it :) – kellogs Nov 10 '11 at 21:42
  • 3
    I tried using google translate with public proxies with no luck. Other people are using the same proxies, and Google knows. – Bashevis Jan 18 '13 at 23:57
1
$translatedText = "प्रशांत कुमार सिंह";
$detectedSourceLanguage = "en";

$url ='https://www.google.com/inputtools/request?text='.urlencode($translatedText).'&ime=transliteration_hi_'.urlencode($detectedSourceLanguage);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_PROXYPORT,3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
$response = curl_exec($ch);
$output = json_decode($response);
$resultText = '';

if($output[0] == 'SUCCESS'){
 if(isset($output[1])){
  if(isset($output[1][0])){
   if(isset($output[1][0][1])){
    $resultText = $output[1][0][1][0];
   }
  }
 }
}
echo  $resultText;
prashant singh
  • 119
  • 1
  • 2