“google translate” vs “translate api”

不问归期 提交于 2019-11-28 01:17:39

问题


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?


回答1:


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.




回答2:


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.




回答3:


$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;


来源:https://stackoverflow.com/questions/8085743/google-translate-vs-translate-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!