PHPackages                             conquer/i18n - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. conquer/i18n

AbandonedYii2-extension[Localization &amp; i18n](/categories/localization)

conquer/i18n
============

The I18n automatic translation extension for the Yii2 framework

1.0.1(11y ago)136923[1 issues](https://github.com/borodulin/yii2-i18n-google/issues)MITPHP

Since Jun 18Pushed 7y ago4 watchersCompare

[ Source](https://github.com/borodulin/yii2-i18n-google)[ Packagist](https://packagist.org/packages/conquer/i18n)[ Docs](https://github.com/borodulin/yii2-i18n-google)[ RSS](/packages/conquer-i18n/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Yii2 I18N Google &amp; Yandex translation services integration
==============================================================

[](#yii2-i18n-google--yandex-translation-services-integration)

Description
-----------

[](#description)

This extension makes it possible to automatically translate messages using external services.

\##Google With [Google Translate](https://cloud.google.com/translate/docs), you can dynamically translate text between thousands of language pairs. The Google Translate API lets websites and programs integrate with Google Translate programmatically. **Google Translate API is available as a paid service**. See the [Pricing](https://cloud.google.com/translate/v2/pricing.html)and [FAQ](https://cloud.google.com/translate/v2/faq.html) pages for details.

\##Yandex [The API](https://tech.yandex.com/translate) provides access to the Yandex online machine translation service. It supports more than 40 languages and can translate separate words or complete texts. The API makes it possible to embed Yandex.Translate in a mobile app or web service for end users. Or translate large quantities of text, such as technical documentation.

Installation
============

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

To install, either run

```
$ php composer.phar require conquer/i18n "*"

```

or add

```
"conquer/i18n": "*"

```

to the `require` section of your `composer.json` file.

To create database tables run migration command

```
$ yii migrate --migrationPath=@conquer/i18n/migrations

```

Usage
=====

[](#usage)

You need to configure Module and i18n component

```
$config = [
    'bootstrap' => ['translate'],
    'language' => 'ru',
    'modules' => [
        'translate' => 'conquer\i18n\Module'
    ],
    'components' => [
        'i18n' => [
            'class' => 'yii\i18n\I18N',
            'translations' => [
                '*' => [
                    'class' => 'conquer\i18n\MessageSource',
                    'translator' => [
                     //   'class'=>'conquer\i18n\translators\GoogleTranslator',
                     //   'apiKey' => 'obtain API key in the google developer console',
                        'class'=>'conquer\i18n\translators\YandexTranslator',
                        'apiKey' => '[yandex form](https://tech.yandex.com/keys/get/?service=trnsl)',
                    ],
                ],
            ],
        ],
    ],
];
```

Use \\Yii::t function to translate messages

```
