If you want to have translations for each module contained in a module, you need to register translations for this module. This cannot be done from the configuration file. You probably already have this in your module file, I just turned on for completeness. The code is copied from the documentation and should be in your module file, so in app/modules/Foo.php
<?php namespace app\modules\foo; use Yii; class Module extends \yii\base\Module { public $controllerNamespace = 'app\modules\foo\controllers'; public function init() { parent::init(); $this->registerTranslations(); } public function registerTranslations() { Yii::$app->i18n->translations['modules/foo/*'] = [ 'class' => 'yii\i18n\PhpMessageSource', 'sourceLanguage' => 'en-US', 'basePath' => '@app/modules/foo/messages', 'fileMap' => [ 'modules/foo/validation' => 'validation.php', 'modules/foo/form' => 'form.php', ... ], ]; } public static function t($category, $message, $params = [], $language = null) { return Yii::t('modules/users/' . $category, $message, $params, $language); } }
In your case, it does not look like you need to provide a file association. You can simply use this format for your files.
[[basePath]]/LanguageID/CategoryName.php
Sorry, I canβt find a list of available categories.
If you want to override some module translations, you need to specify the category that will be used, for example, in your configuration file. It specifically redefines the module category / foo / bar.
'i18n' => [ 'translations' => [ 'modules/foo*' => [ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => '@app/messages', ], ], ],
Your translation file should follow the folder structure, as in the description of the translation, so in the example above it will be
app/messages/ [language code] /modules/foo/bar.php
In other words, you can use fileMap for matching in different places, for example, if your bar.php file is in the application / messages / [language code]
'fileMap' => [ 'modules/foo/bar' => 'bar.php' ]