【发布时间】:2011-12-26 12:14:57
【问题描述】:
我听说翻译 API 会收费,但究竟是什么阻止了我们免费使用免费的 Google 翻译服务here?不然的话,免费服务有什么限制?
【问题讨论】:
-
我投票决定将此问题作为题外话结束,因为这是一个需要 Google 技术支持的问题。
标签: google-translate google-translation-api
我听说翻译 API 会收费,但究竟是什么阻止了我们免费使用免费的 Google 翻译服务here?不然的话,免费服务有什么限制?
【问题讨论】:
标签: google-translate google-translation-api
根据下面的链接,没有什么能阻止你。
https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=es&dt=t&q=Hello
将您的请求 content-type 设置为 application/json 并修复了奇怪的格式,我在 google 网站上抨击了一段时间后发现了 uri 模式。
我不建议用它翻译圣经,但我这周已经完成了大约 10k 字,没有问题。
如果有人找到另一个有效的 client 值,我很想知道。
【讨论】:
&ie=UTF-8&oe=UTF-8 应该包含在您的 URL 中,并且不要忘记将 WebClient 设置为 Encoding = Encoding.UTF8
<p id="textField">You can translate the <span class="notranslate" translate="no" > not this part</span> this by selecting a language in the select box.</p>
除了可访问性之外,没有什么能阻止您使用 Google 翻译网站。与尝试通过框架将 Google 翻译嵌入您的网站相比,公共 API 为您提供了更紧密的集成。
【讨论】:
$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;
【讨论】: