function babyloncevir($text,$from,$to){ //0=>İngilizce,1=>Fransız,2=>İtalyanca,6=>Alman,5=>Portekizce,3=>İspanyolca,15=>Arapça,99=>Catalan,344=>Kastilya,31=>Çek,10=>Çince (s),9=>Çince (t),43=>Danimarkalı,11=>Yunan,14=>İbranice,60=>Hintçe,30=>Macar,51=>Farsça,8=>Japon,12=>Kore,4=>Hollandalı,46=>Norveç,29=>Polonya,47=>Romanian,7=>Rus,48=>İsveç,13=>Türk,16=>Tayland,49=>Ukrayna,39=>Urduca $url='http://translation.babylon.com/translate/babylon.php?v=1.0&q='; $url.=rawurlencode($text).'&langpair='.$from.'%7C'.$to.'&callback=babylonTranslator.callback'; $url.='.&context=babylon.'.$from.'.'.$to.'._babylon_api_response'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); curl_setopt($ch, CURLOPT_TIMEOUT, 120); curl_setopt($ch, CURLOPT_URL, $url); $html = curl_exec($ch); curl_close($ch); preg_match("#{(.*?)}#si",$html,$s); $j=json_decode($s[0],true); return $j["translatedText"]; }
Kullanımı
echo babyloncevir("what is your name",0,13);