#GoogleTranslator API
function translate($text, $from, $to) {
$text = urlencode($text);
$api = "https://x.wwi.su/x/translator/";
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $api."?text=$text&from=$from&to=$to",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => "PHPiB",
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
header('Content-Type: application/json');
echo translate($_GET["text"], $_GET["from"], $_GET["to"]);
to - tarjima bo'ladigan til
from - qaysi tildan tarjima bo'lishi avtomatik qilish uchun shunchaki bo'sh qoldiring
text - tarjima bo'ladigan til
Xar bir til kodlari:
https://en.m.wikipedia.org/wiki/List_of_ISO_639_language_codes