wfstudioru / yii2-yandex-translate-api
Yii2 extension to Yandex Translate API
Package info
github.com/wfstudioru/yii2-yandex-translate-api
Type:yii2-extension
pkg:composer/wfstudioru/yii2-yandex-translate-api
dev-master
2015-05-02 20:36 UTC
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2026-03-18 14:31:27 UTC
README
Yandex Translate API
Installation
The preferred way to install this extension is through composer.
Either run
$ php composer.phar require wfstudioru/yii2-yandex-translate-api "dev-master"
or add
"wfstudioru/yii2-yandex-translate-api": "dev-master"
to the require section of your composer.json file.
Usage
Create Yandex API Key (free to use)
- Go to the Yandex Translate API Site.
- Create new API Key.
Component Configuration
'components' => [ ... 'translate' => [ 'class' => 'wfstudioru\translate\Translation', 'key' => 'INSERT-YOUR-API-KEY', ], ... ],
Yii::$app->translate->translate($source, $target, $text);
Usage
Yii::$app->translate->translate('en-US', 'ru-RU', 'Hi everybody!');
the response would be:
array ( 'code' => 200, 'lang' => 'en-ru', 'text' => array ( 0 => 'Привет всем!' ) )