嘿嘿~我也没看懂啊,不知道能不能用,你多测两下,hi,look,电脑! 注: Translation: $20 per 1 M characters of text, where the charges are adjusted in proportion to the number of characters actually provided. Language Detection: $20 per 1 M characters of text, where the charges are adjusted in proportion to the number of characters actually provided.
class Google_API_translator {
public $out = "";
function translate($text) {
$this->out = "";
$text = urlencode($text);//要翻译的单词
$google_translator_url = "http://translate.google.com/translate_a/t?client=t&text=".$text."&sl=en&tl=zh_CN";
$gphtml = $this->postPage(array("url" => $google_translator_url));
$this->out = $gphtml;
return $this->out;
}
function postPage($opts) {
$html = "";if($opts["url"] != "") {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $opts["url"]); $html = curl_exec($ch);if(curl_errno($ch)) $html = "";
curl_close ($ch);
}return $html;
}
}
$g = new Google_API_translator();
$g->translate("computer");没用过,你捉摸捉摸吧~~反过来,编码要改
注: Translation:
$20 per 1 M characters of text, where the charges are adjusted in proportion to the number of characters actually provided.
Language Detection:
$20 per 1 M characters of text, where the charges are adjusted in proportion to the number of characters actually provided.
&sl=en&tl=zh_CN
我敢说,这地方很奇怪的
数组的
第一个元素为一数组,依次为 中文词汇、英文词汇、汉语拼音
第二个元素为一数组,依次为 词性、同义词数组,同义词中英对照数组
再后面的意义不大,是为生成页面元素而设的你在google翻译页面测试一下就知道了
Translate This Button 这个玩意儿整页翻译的不错
摆弄摆弄选项卡和下拉框,在看看源码
http://translate.google.cn/?hl=zh-CN&tab=wT#en/zh-CN/
http://translate.google.cn/?hl=zh-CN&tab=wT#zh-CN/en/
http://translate.google.cn/?hl=zh-CN&tab=wT#ja/en/
http://translate.google.cn/?hl=zh-CN&tab=wT#ja/fr/