Добрый день, Дмитрий.
Почитала ваши обучающие материалы.
Там этого еще нет - попыталась в исходниках разобраться.
Мне понравилась идея перенести переводы в модули.
И я смотрю у Вас идея эта реализована.
Но судя по коммитам, были метания между разными решениями.
Вот идея с AdminModule:t('admin', 'MESSAGE') у меня заработала.
папки переводов лежат в modules\admin\messages\en|ru
В модуле прописано следующее
public function registerTranslations() {
Yii::$app->i18n->translations['modules/admin/*'] = [
'class' => 'yii\i18n\PhpMessageSource',
'sourceLanguage' => 'en',
'basePath' => '@app/modules/admin/messages/',
'fileMap' => [
'modules/admin/admin' => 'admin.php',
],
];
}
public static function t($category, $message, $params = [], $language = null) {
return Yii::t('modules/admin/'.$category, $message, $params, $language);
}
Но я догадываюсь почему вы отказались от этого метода.
Писать каждый раз
use app\modules\admin\Module as AdminModule;
не очень хочется.
PS. в идеале хотелось бы использовать конструкцию внутри модуля
Yii::t('admin', .......
или Yii::t('admin-error', .......
при этом хранить файлы admin.php и admin-error.php внутри модуля admin
Как же всё таки реализовано у Вас сейчас.
Хотя настройки, я смотрю, вы выкинули, но файлы сообщений все же в модулях.
Спасибо, заранее