bende şimdi bu sekilde yapmıstım yardım gelmeyince. Kod kalabalığı olmasın diye daha kısa nasıl halledilir diye öneriler bekliyordumda sizden başka ugrasan olmadı sağolun hocam böyle kullanayım
anlayabileceğiniz derecede basitleştirerek yazdım.
tabi bu dili yeni öğreniyorsanız, fonksiyon veya class olarak çalışmanız en mantıklı yol olacaktır, öğrenmeye çalışın.
kullanıp geçecekseniz bu işinizi çözer.
<?php
$apiKey = '<paste your API key here>';
//Ilk Ceviri TR - ENG
$text = 'Hello world!';
$url = 'https://www.googleapis.com/language/translate/v2?key=' . $apiKey . '&q=' . rawurlencode($text) . '&source=tr&target=en';
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($handle);
$responseDecoded = json_decode($response, true);
curl_close($handle);
$text_tr_eng = $responseDecoded['data']['translations'][0]['translatedText'];
//Ikinci Ceviri ENG - TR
$text2 = $text_tr_eng;
$url2 = 'https://www.googleapis.com/language/translate/v2?key=' . $apiKey . '&q=' . rawurlencode($text2) . '&source=en&target=tr';
$handle2 = curl_init($url2);
curl_setopt($handle2, CURLOPT_RETURNTRANSFER, true);
$response2 = curl_exec($handle2);
$responseDecoded2 = json_decode($response2, true);
curl_close($handle2);
$text_eng_tr = $responseDecoded2['data']['translations'][0]['translatedText'];
//Yazdır
print "1- ". $text_tr_eng;
print "<br>"
print "2- ". $text_eng_tr;
?>