composer require stichoza/google-translate-php
$newData isimli dizi çevirilen degerleri içerir.
$tr->setTarget’in içindeki dili degistirerek veriyi google translate’in çevirebildiği tüm dillere gore çıktısını alabilirsiniz
require_once __DIR__ . '/vendor/autoload.php';
use Stichoza\GoogleTranslate\GoogleTranslate;
$tr = new GoogleTranslate();
$tr->setSource('en');
$tr->setTarget('tr');
$data = array(
"StackPanel1.TopWrapper.lbName.Caption=Selected machine name",
"StackPanel1.TopWrapper.PanelStatus.lbOnlineStatus.Caption=Status: Unknown",
"StackPanel1.MainWrapper.Label2.Caption=Enable Monitoring",
"StackPanel1.MainWrapper.Label3.Caption=Run Backup",
"StackPanel1.MainWrapper.Label4.Caption=Show Report",
"StackPanel1.ccbConnect.Caption=Connect"
);
$newData = [];
foreach($data as $string){
$length = strlen($string);
$findMarker = strpos($string, "=");
$newString = mb_substr($string, $findMarker + 1, $length - $findMarker, "UTF-8");
$translate = $tr->translate($newString);
$newData[$string] = $translate;
}
echo "";
print_r($newData);