richweber / yii2-google-translate-api
Yii2 extension to Google Translate API
Installs: 35 922
Dependents: 2
Suggesters: 0
Security: 0
Stars: 7
Watchers: 4
Forks: 3
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-12-13 11:16:48 UTC
README
Google Translate API
Installation
The preferred way to install this extension is through composer.
Either run
$ php composer.phar require richweber/yii2-google-translate-api "dev-master"
or add
"richweber/yii2-google-translate-api": "dev-master"
to the require
section of your composer.json
file.
Usage
Identifying your application to Google
If you haven't done so already, create your project's API key by following these steps:
- Go to the Google Developers Console.
- Select a project, or create a new one.
- In the sidebar on the left, expand APIs & auth. Next, click APIs. In the list of APIs, make sure the status is ON for the Google Translate API.
- In the sidebar on the left, select Credentials.
- To create an API key, click Create new Key and select the appropriate key type. Enter the additional information required for that key type and click Create.
Component Configuration
'components' => [ ... 'translate' => [ 'class' => 'richweber\google\translate\Translation', 'key' => 'INSERT-YOUR-API-KEY', ], ... ],
Yii::$app->translate->translate($source, $target, $text);
Yii::$app->translate->discover();
Yii::$app->translate->detect($text);
License
yii2-twitter is released under the BSD 3-Clause License. See the bundled LICENSE.md
for details.