PHP code example of sadonsergey / yc-ml-translate
1. Go to this page and download the library: Download sadonsergey/yc-ml-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/ */
sadonsergey / yc-ml-translate example snippets
$yandexTranslate = new ssadon\YandexTranslate($OAuthToken, $IAMToken, $folderId);
//Translating text
$text = $yandexTranslate->translate('en', 'ru', 'cat');
echo $text['text']; //кошка
//You can use multiple translation
$text = $yandexTranslate->translate('en', 'ru', ['cat', 'dog']);
echo $text[0]['text']; //кошка
echo $text[1]['text']; //собака
//Detecting language
$detect = $yandexTranslate->detectLanguage('English text');
echo $detect; //en