【问题标题】:How to increase translating content size in Google translator API如何在 Google 翻译 API 中增加翻译内容的大小
【发布时间】:2013-01-31 16:43:34
【问题描述】:

我正在使用谷歌翻译 API。

function curl($url,$params = array(),$is_coockie_set = false)
{

if(!$is_coockie_set){
/* STEP 1. let’s create a cookie file */
$ckfile = tempnam ("/tmp", "CURLCOOKIE");

/* STEP 2. visit the homepage to set the cookie properly */
$ch = curl_init ($url);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
}

$str = ''; $str_arr= array();
foreach($params as $key => $value)
{
$str_arr[] = urlencode($key)."=".urlencode($value);
}
if(!empty($str_arr))
$str = '?'.implode('&',$str_arr);

/* STEP 3. visit cookiepage.php */

$Url = $url.$str;

$ch = curl_init ($Url);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec ($ch);
return $output;
}

在此 Google API 中,仅翻译了 500 个字符。

function Translate($word,$conversion)
{
$word = urlencode($word);
$url = 'http://translate.google.com/translate_a/t?client=t&text='.$word.'&hl=en&sl=en&tl=fr&ie=UTF-8&oe=UTF-8&multires=1&otf=1&ssel=3&tsel=3&sc=1';
}

这是用于翻译内容的功能。我要翻译超过 500 个字符。 请给我建议。

【问题讨论】:

  • 您是否使用付费的免费版 API,因为您必须为此付费。 developers.google.com/translate/v2/faq - 如果你付钱; What is the maximum number of characters per request? The maximum size of each text to be translated is 5000 characters, not including any HTML tags.

标签: php google-translate


【解决方案1】:

见于:How to increase translating content size in Google translator API

有免费配额吗? 不可以,Google Translate API 仅作为付费服务提供。有关详细信息,请参阅定价和支持。不过,我们确实提供了 Google 网站翻译小工具,它可以免费翻译您的网站。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-27
    • 1970-01-01
    • 1970-01-01
    • 2015-10-08
    • 2021-07-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多