1. Go to this page and download the library: Download mantoufan/yzhantranslator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$json = json_encode(['k' => '你好']);
$prompt = 'If there is a key named \'k\', retain the original value, but add a new key \'k2\' at the same level, containing the translated value.';
$result = $translator->translate($json, 'en', [
'type' => 'json',
'prompt' => $prompt
]);
print_r($result); // ['k' => '你好', 'k2' => 'Hello']