dev-master
9999999-devi18n for javascript files
The Requires
- php >=5.6
- yiisoft/yii2 *
by Arthur Ferreira Silva
yii i18n
i18n for javascript files
Add in your composer.json file
"gleads/yii18n": "dev-master"
, (*1)
Then run in your terminal:
composer update
, (*2)
You must add the translator module in your config/web.php, (*3)
'modules' => [ 'translator' => [ 'class' => 'gleads\yii18n\TranslatorModule' ] ],
Add the class message source with class 'gleads\yii18n\PhpMessageSource', (*4)
'components' => [ 'i18n' => [ 'translations' => [ 'app*' => [ 'class' => 'gleads\yii18n\PhpMessageSource', // Add This class 'fileMap' => [ 'app' => 'app.php', 'app/error' => 'error.php', ], ], ], ], ],
note: you need set urlmanager > enablePrettyUrl as true
, (*5)
in your view you must add the translator asset:, (*6)
gleads\yii18n\TranslatorAsset::register($this);
then it's already to use you can use like yii::t() style, (*7)
in your js file:, (*8)
yii.t('category', 'message', 'params');
i18n for javascript files
yii i18n