How to translate data obtained via Json to another language?

Good time of day.
Wanted to know if there are ways to translate data in Json format received from the server to another language ?
Meaning from English to Russian .
June 8th 19 at 16:52
1 answer
June 8th 19 at 16:54
Solution
You can use the API Translator Yandex https://tech.yandex.ru/translate/

Daily limit of queries is 1,000,000 characters, month — 10 000 000 characters. To increase the limit of requests, go to the paid version of the service.


Either find another interface interaction.

PHP:
function translate($text) {
 $api_key = "; // Specify the generated API key
 $lang = 'en-EN';

 $text = urlencode($text);

 $link = 'https://translate.yandex.net/api/v1.5/tr.json/translate?key=' . $api_key . '&text='. $text . '&lang=' . $lang;

 $result = json_decode(file_get_contents($link), true);

 return $result['text'][0];
}

$response = [];

$response['errors'][] = 'First Error';
$response['errors'][] = 'Second Error';
$response['errors'][] = 'Third Error';

foreach ($response['errors'] as $key => $value) {
 $response['errors'][$key] = translate($value);
}

return json_encode($response, JSON_UNESCAPED_UNICODE);


Similarly for JavaScript. Take the error text sent to the function, the function sends a transfer request and returns the result.

Find more questions by tags APIMachine translation from one language to another