feat: add automated scripts and JSON datasets for managing and translating site content

This commit is contained in:
Ümit Tunç
2026-05-20 00:03:07 +03:00
parent 29ddc24602
commit 19c9202fc1
14 changed files with 9741 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
<?php
function translateText($text, $from = 'tr', $to = 'en') {
$url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" . $from . "&tl=" . $to . "&dt=t&q=" . urlencode($text);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36");
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$response = curl_exec($ch);
curl_close($ch);
if (!$response) {
return false;
}
$data = json_decode($response, true);
if (!isset($data[0])) {
return false;
}
$translated = "";
foreach ($data[0] as $sentence) {
$translated .= $sentence[0];
}
return $translated;
}
$test = translateText("Merhaba Dünya! Web Uygulamaları ve Nesnelerin İnterneti geliştirmekteyiz.");
echo "Original: Merhaba Dünya! Web Uygulamaları ve Nesnelerin İnterneti geliştirmekteyiz.\n";
echo "Translated: " . $test . "\n";