Tags: Google Translate Script
function translate($s,$d,$q){
// Basic request parameters:
// s = source language
// d = destination language
// q = Text to be translated
$lang_pair = urlencode($s.’|’.$d);
$q = urlencode($q);
// Google’s API translator URL
$url = “http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=”.$q.”&langpair=”.$lang_pair;
// Make sure to set CURLOPT_REFERER because Google doesn’t like if you leave the referrer out
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, “http://www.yoursite.com/translate.php“);
$body = curl_exec($ch);
curl_close($ch);
$json = json_decode($body, true);
return $json['responseData']['translatedText'];
}ไม่แน่ใจว่า ลอก script นี้มาจากเว็บไหน แต่มันก็โอเค เรียกใช้ Google API แปลได้หลายภาษาเลย แต่บางจังหวะก็ไม่ work สงสัย google ทำงานไม่ทันมั้ง
January 12th, 2011 at 00:04
This is a best weblog. I mean it. You’ve got a better agreement thought of this matter, and so much interest you have got a layout here that is not too flashy, but plots a statement as gigantic as what youre expressing. Better job!.