Skip to content

stratoss/yii2-google-translate-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

original project

Yii2 extension to Google Translate API

Google Translate API

Installation

The preferred way to install this extension is through composer.

Either run

$ php composer.phar require stratoss/yii2-google-translate-api "dev-master"

or add

"stratoss/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:

  1. Go to the Google Developers Console.
  2. Select a project, or create a new one.
  3. 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.
  4. In the sidebar on the left, select Credentials.
  5. 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.

Read more...

Component Configuration

'components' => [
    ...
    'translate' => [
        'class' => 'stratoss\google\translate\Translation',
        'key' => 'INSERT-YOUR-API-KEY',
    ],
    ...
],
Yii::$app->translate->translate($source, $target, "Hello World");
Yii::$app->translate->translate($source, $target, ["Hello World", "Hello, my name is John Doe"]);
Yii::$app->translate->discover();
Yii::$app->translate->detect($text);

License

yii2-google-translate-api is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.

About

Yii2 extension for Google Translate API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%