devnullius / yii2-i18n-module
Yii2 i18n module makes the translation of your application simple
Installs: 3 343
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- php: >=7.1.0
- yiisoft/yii2: ~2.0.26
README
Yii2 i18n (internalization) module makes the translation of your application so simple
Installation
Composer
The preferred way to install this extension is through Composer.
Either run
php composer.phar require devnullius/yii2-i18n-module
or add
"devnullius/yii2-i18n-module": "^1.0"
to the require section of your composer.json
Usage
Configure I18N component in common config:
'i18n' => [ 'class' => devnullius\yii\modules\i18n\components\I18N::class, 'languages' => ['ru-RU', 'de-DE', 'it-IT'] ],
Configure I18N component in backend config:
'modules' => [ 'i18n' => devnullius\yii\modules\i18n\Module::class ],
Run:
php yii migrate --migrationPath=@devnullius/yii/modules/i18n/migrations
Go to http://backend.yourdomain.com/translations
for translating your messages
PHP to DB import
If you have an old project with PHP-based i18n you may migrate to DbSource via console.
Run:
php yii i18n/import @common/messages
where @common/messages
is path for app translations
DB to PHP export
Run:
php yii i18n/export @devnullius/yii/modules/i18n/messages i18n
where @devnullius/yii/modules/i18n/messages
is path for app translations and i18n
is translations category in DB
Using yii
category with DB
Import translations from PHP files
php yii i18n/import @yii/messages
Configure I18N component:
'i18n' => [ 'class'=> devnullius\yii\modules\i18n\components\I18N::class, 'languages' => ['ru-RU', 'de-DE', 'it-IT'], 'translations' => [ 'yii' => [ 'class' => yii\i18n\DbMessageSource::class ] ] ],
Info
Component uses yii\i18n\MissingTranslationEvent for auto-add of missing translations to database
See Yii2 i18n guide
Author
Aleksandr Zelenin, e-mail: aleksandr@zelenin.me
Improver
Aram Harutyunyan, e-mail: aram.ds@gmail.com