2017 © Pedro Peláez
 

yii2-extension i18n

The I18n automatic translation extension for the Yii2 framework

image

conquer/i18n

The I18n automatic translation extension for the Yii2 framework

  • Monday, July 27, 2015
  • by borodulin
  • Repository
  • 2 Watchers
  • 4 Stars
  • 189 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 6 % Grown

The README.md

Yii2 I18N Google & Yandex translation services integration

Description

This extension makes it possible to automatically translate messages using external services., (*1)

Google

With Google Translate, 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 and FAQ pages for details., (*2)

Yandex

The API 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., (*3)

Installation

The preferred way to install this extension is through composer., (*4)

To install, either run, (*5)

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

or add, (*6)

"conquer/i18n": "*"

to the require section of your composer.json file., (*7)

To create database tables run migration command, (*8)

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

Usage

You need to configure Module and i18n component, (*9)

$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, (*10)

<h1><?= \Yii::t('app', 'Congratulations!') ?></h1>

"*" Translation category is used by default for all non-translated messages., (*11)

You can configure a separate category for the translation of messages by external translator., (*12)

    'components' => [
        'i18n' => [
            'class' => 'yii\i18n\I18N',
            'translations' => [
                'yandex' => [
                    'class' => 'conquer\i18n\MessageSource',
                    'translator' => [
                        'class'=>'conquer\i18n\translators\YandexTranslator',
                        'apiKey' => '[yandex form](https://tech.yandex.com/keys/get/?service=trnsl)',
                    ],
                ],
            ],
        ],
    ],

Use \Yii::t function to translate messages in "yandex" category, (*13)

<h1><?= \Yii::t('yandex', 'Congratulations!') ?></h1>

License

conquer/i18n is released under the MIT License. See the bundled LICENSE.md for details., (*14)

The Versions

27/07 2015

dev-master

9999999-dev https://github.com/borodulin/yii2-i18n-google

The I18n automatic translation extension for the Yii2 framework

  Sources   Download

MIT

The Requires

 

yii2 i18n yandex-translate google-translate

18/06 2015

1.0.1

1.0.1.0 https://github.com/borodulin/yii2-i18n-google

The I18n automatic translation extension for the Yii2 framework

  Sources   Download

MIT

The Requires

 

yii2 i18n yandex-translate google-translate