Gii - CRUD error: Unable to locate message source for category 'modules/profile'. (modules messages)

Hi, I have tried to use the Gii’s CRUD module. I wanted to create CRUD controller and views with i18n.

It is does not find the message source category, but why not?

I followed the guide, but I missing some informations in the guide.

Lets see, I create a Profile module and I added i18n like in Guide:

class Profile extends \yii\base\Module



     * @inheritdoc


    public $controllerNamespace = 'frontend\modules\Profile\controllers';


     * @inheritdoc


    public function init()





    public function registerTranslations()


        Yii::$app->i18n->translations['modules/profile/*'] = [

            'class' => 'yii\i18n\PhpMessageSource',

            'sourceLanguage' => 'en-US',

            'basePath' => '@frontend/modules/profile/messages',

            'fileMap' => [

                'modules/profile' => 'profile.php',

                'modules/profile/validation' => 'validation.php',

                'modules/profile/form' => 'form.php',




    public static function t($category, $message, $params = [], $language = null)


        return Yii::t('modules/profile/' . $category, $message, $params, $language);



The messages files are created under

  • frontend/modules/profile/messages/de/modules/profile.php

  • frontend/modules/profile/messages/es/modules/profile.php

  • frontend/modules/profile/messages/hu/modules/profile.php

So what are going to wrong? I have no idea. :-[

By the way I have frontend/config/i18n.php

// string, required, root directory of all source files

    'sourcePath' => __DIR__ . DIRECTORY_SEPARATOR . '..',

    // array, required, list of language codes that the extracted messages

    // should be translated to. For example, ['zh-CN', 'de'].

    'languages' => ['en-GB', 'de-DE', 'es-ES', 'hu-HU'],

    // string, the name of the function for translating messages.

    // Defaults to 'Yii::t'. This is used as a mark to find the messages to be

    // translated. You may use a string for single function name or an array for

    // multiple function names.

    'translator' => 'Yii::t',

    // boolean, whether to sort messages by keys when merging new messages

    // with the existing ones. Defaults to false, which means the new (untranslated)

    // messages will be separated from the old (translated) ones.

    'sort' => false,

    // boolean, whether to remove messages that no longer appear in the source code.

    // Defaults to false, which means these messages will NOT be removed.

    'removeUnused' => false,

    // boolean, whether to mark messages that no longer appear in the source code.

    // Defaults to true, which means each of these messages will be enclosed with a pair of '@@' marks.

    'markUnused' => true,

    // array, list of patterns that specify which files (not directories) should be processed.

    // If empty or not set, all files will be processed.

    // Please refer to "except" for details about the patterns.

    'only' => ['*.php'],

    // array, list of patterns that specify which files/directories should NOT be processed.

    // If empty or not set, all files/directories will be processed.

    // A path matches a pattern if it contains the pattern string at its end. For example,

    // '/a/b' will match all files and directories ending with '/a/b';

    // the '*.svn' will match all files and directories whose name ends with '.svn'.

    // and the '.svn' will match all files and directories named exactly '.svn'.

    // Note, the '/' characters in a pattern matches both '/' and '\'.

    // See helpers/FileHelper::findFiles() description for more details on pattern matching rules.

    // If a file/directory matches both a pattern in "only" and "except", it will NOT be processed.

    'except' => [









    // 'php' output format is for saving messages to php files.

    'format' => 'php',

    // Root directory containing message translations.

    'messagePath' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'messages',

    // boolean, whether the message file should be overwritten with the merged messages

    'overwrite' => true,

Least I have have the following configuration frontend/config/main.php

return [

    'id' => 'app-frontend',

    'basePath' => dirname(__DIR__),

    'bootstrap' => ['log'],

    'controllerNamespace' => 'frontend\controllers',

    'components' => [

        'user' => [

            'identityClass' => 'common\models\User',

            'enableAutoLogin' => true,


        'i18n' => [

            'translations' => [

                'app*' => [

                    'class' => 'yii\i18n\PhpMessageSource',

                    'sourceLanguage' => 'en-US',

                    'basePath' => '@frontend/messages',

                    'fileMap' => [

                        'app' => 'app.php',

                        'app/error' => 'error.php',





        // ...


    'modules' => [

        'Profile' => [

            'class' => 'frontend\modules\Profile\Profile',



    'params' => $params,



I have some questions

  • Can a Yii developer update guide?

  • What is the difference between the common/config and environment/dev/common/config? (What for the enviromnets? Because It seems the Yii never use those files…)

  • Why Yii use only the common/config files? If I am at the frontend or at the backend, yii never uses the backend/config or frontend/config files.

  • Why Yii does not use the module files configuration?

The solution was… copy every configurations into the common/config/main.php.

I wasted my all day with this one configuration and I am very affraid when I will want to deploy my yii application I will get more configuration errors.