Codeception don't recognize modules' translation

(mark116) #1

I’ve followed this Yii2 tutorial in order to translate my modules’ messages separately from my main app.

In my module.php file I’ve created the ‘registerTranslations’ and the ‘t’ method.

Unfortunately, when I tried to test my modules with codeception I recideved this message: " [yii\base\InvalidConfigException] Unable to locate message source for category 'modules/…".

It’s possible that my test application does not recognize the translation? How can I solve?

Thak you

(mark116) #2

Same problem occurs when I try to generate CRUD template with Gii.

This is the the code of my Module.php

public function init()

 * Add translation configurations
public function registerTranslations()
    Yii::$app->i18n->translations['modules/MODULENAME/*'] = [
        'sourceLanguage' => 'en-US',
        'class'    => 'yii\i18n\PhpMessageSource',
        'basePath' => '@app/modules/MODULENAME/messages',
        'fileMap'  => [
            'modules/MODULENAME/TNAME' => 'app.php',

 * Register translate method
public static function t($category, $message, $params = [], $language = null)
    return Yii::t('modules/money/' . $category, $message, $params, $language);