I am trying to configure the translation of a site interface using i18l. Here is my i18l.php file located on the / config interface
<?php return [ 'sourcePath' => 'frontend', 'languages' => ['en-US', 'pt-BR'] , //Add languages to the array for the language files to be generated. 'translator' => 'Yii::t', 'sort' => false, 'removeUnused' => false, 'only' => ['*.php'], 'except' => [ '.svn', '.git', '.gitignore', '.gitkeep', '.hgignore', '.hgkeep', '/messages', '/vendor', ], 'format' => 'php', 'messagePath' => 'frontend' . DIRECTORY_SEPARATOR . 'translations', 'overwrite' => true, ];
and here is my main.php also on the interface
(...) 'language' => 'en-US', 'components' => [ 'i18n' => [ 'translations' => [ 'app*' => [ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => 'frontend/translations', 'fileMap' => [ 'app' => 'app.php', 'app/error' => 'error.php', ], ], ], ]
I use <?= Yii::t('app', 'some string') ?> On sites and layouts, and when I run the command. / yii message / extract @ frontend / config / i18n.php, it creates for me a folder called "translations" containing the other two folders "en-US" and "pt-BR" as with app.php, which I already filled some translations. But, nevertheless, the translation does not happen when I change the language to main.php, as it should be (I think). I would appreciate it if someone could help me.
Thanks.
php yii yii2-advanced-app
Alessandro resta
source share