Translate content using YandexTranslateAPI
Translate content using YandexTranslateAPI, (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist pashkinz92/yii2-yandex-translate "*"
or add, (*4)
"pashkinz92/yii2-yandex-translate": "*"
to the require section of your composer.json
file., (*5)
Usage
'components' => [
...
'translate' => [
'class' => \pashkinz92\yandex\translate\Translation::className(),
'key' => 'yandexTranslateApiKey',
],
...
]
Once the extension is installed, simply use it in your code by :, (*6)
$lang = Yii::$app->translate->detect('Hello !');
echo '<pre>';
var_dump($lang);
echo '</pre>';