function Translate-ToTr {
param (
[string]$text
)
$encoded = [System.Web.HttpUtility]::UrlEncode($text)
$url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=tr&dt=t&q=$encoded"
try {
$result = Invoke-RestMethod -Uri $url -Method Get
return $result[0][0][0]
} catch {
return "[Çevrilemedi]"
}
}
$jsonPath = "Orginal.json"
$outputPath = "Output.json"
$json = Get-Content $jsonPath | ConvertFrom-Json
$translated = @{}
foreach ($key in $json.PSObject.Properties.Name) {
$translated[$key] = Translate-ToTr $json.$key
Start-Sleep -Milliseconds 300
}
$translated | ConvertTo-Json -Depth 10 | Out-File -Encoding UTF8 $outputPath