dvixi / yii2-i18n
Yii2 i18n (internalization) module makes the translation of your application so simple
Installs: 62
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ~2
This package is not auto-updated.
Last update: 2024-11-13 18:03:54 UTC
README
added caching for messages and source messages
modification of Zelenin Yii2 i18n
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 dvixi/yii2-i18n "dev-master"
or add
"dvixiyii2-i18n": "dev-master"
to the require section of your composer.json
Usage
Configure I18N component in common config:
'i18n' => [ 'class' => dvixi\yii2\I18n\components\I18N::className(), 'languages' => ['ru-RU', 'de-DE', 'it-IT'] ],
Configure I18N component in backend config:
'modules' => [ 'i18n' => dvixi\yii2\I18n\Module::className() ],
Run:
php yii migrate --migrationPath=@Zelenin/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 @dvixi/yii2/I18n/messages dvixi/yii2/i18n
where @dvixi/yii2/I18n/messages
is path for app translations and zelenin/modules/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'=> dvixi\yii2\I18n\components\I18N::className(), 'languages' => ['ru-RU', 'de-DE', 'it-IT'], 'translations' => [ 'yii' => [ 'class' => yii\i18n\DbMessageSource::className() ] ] ],
Info
Component uses yii\i18n\MissingTranslationEvent for auto-add of missing translations to database
See Yii2 i18n guide
Source author
Aleksandr Zelenin, e-mail: aleksandr@zelenin.me