PHP code example of tsyvkunov / yandex-cloud-translate
1. Go to this page and download the library: Download tsyvkunov/yandex-cloud-translate 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/ */
tsyvkunov / yandex-cloud-translate example snippets
use Tsyvkunov\YandexCloudTranslate\Translate;
$translate = new Translate('oAuthToken', 'folderId');
use Tsyvkunov\YandexCloudTranslate\Translate;
$translate = new Translate('iamToken');
use Tsyvkunov\YandexCloudTranslate\Translate;
$translate = new Translate();
$translate->makeApi('apiKey');
use Tsyvkunov\YandexCloudTranslate\Translate;
/*
* Получение текущего формата для перевода
*/
echo $translate->getFormat();
/*
* Выбор формата для перевода, по умолчанию PLAIN_TEXT
*/
$translate->setHtmlFormat();
$translate->setPlaintTextFormat();
/*
* Строка/массив строк для перевода
* Язык, на который переводится текст
* Язык, с которого переводится текст (необязательный параметр)
*/
print_r($translate->translate('Hello world', 'en'));
// ИЛИ
print_r($translate->translate(['Hello world', 'Well done'], 'en'));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.