Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP语言转换器_Php_Translate - Fatal编程技术网

PHP语言转换器

PHP语言转换器,php,translate,Php,Translate,我有一个脚本,我正在使用它将英语文本转换为其他口语,我有一个php代码处理它,就像这样 ini_set("max_execution_time", "300"); header('Content-Type: text/html; charset=utf-8'); require_once('googleTranslate.class.php'); $gt = new Google_Translate_API(); $title = $gt->translate($title, "en",

我有一个脚本,我正在使用它将英语文本转换为其他口语,我有一个php代码处理它,就像这样

ini_set("max_execution_time", "300");
header('Content-Type: text/html; charset=utf-8');
require_once('googleTranslate.class.php');
$gt = new Google_Translate_API();

$title = $gt->translate($title, "en", $lang);
$keywords = $gt->translate($keywords, "en", $lang);
$body = $gt->translate($body, "en", $lang);
不管怎样,当我运行这个脚本时,它在能够翻译很多文本之前就超时了,所以我想知道我们是否可以一次运行一个片段

另外,请注意googleTranslate.class.php可以从Google代码免费下载


干杯

嗯,我想你首先应该缓存结果。制作一些脚本以缓存所需语言的翻译内容。否则你的速度将达到查询限制。

明白了。事实证明,谷歌翻译API不是一个好办法。相反,我使用的是Bing翻译服务。它也没有限制我的文本长度。谢谢你的帮助

翻译三段文字时超时?可以免费下载,但服务器端API不再免费:Google Translate API v2现在作为付费服务提供。2011年8月24日之前创建的现有Translate API v2项目的礼貌限制将于2011年12月1日降至零。。。Google Translate API v1将于2011年12月1日完全关闭: