The message file for category 'yii' does not exist

Hello,

I’m always getting this message in log files:


[127.0.0.1][-][-][error][yii\i18n\PhpMessageSource::loadMessages] The message file for category 'yii' does not exist: F:\wamp\www\website1\vendor\yiisoft\yii2/messages/en/yii.php

How could that be disabled/fixed?

Hi

Someone? Also have this doubt…

Could we please bump this message, becouse it seems i’m not the only one with this problem. Anybody has an answer or at least some hints?

It could happen if you’re translating from language X to English i.e. you’ve changed source language and your target language is “en”.

Not translating from any language and did not select the translation option when creating models.

This error is fatal ("Unknown Property") if using the Yii debugger.

Found we can get this error if an attribute is incorrectly named in the model class.

Thank you very much for response.

I happen to have sourceLanguage kept as “en-US”, and target language (Yii::$app->language) is “en”. I’ve been using this module for detecting language from URL: https://github.com/zelenin/yii2-i18n-module

My workaround was to create a class I18N under common\components (well, using advanced template) and just place this function:


class I18N extends \Zelenin\yii\modules\I18n\components\I18N {

    public function translate($category, $message, $params, $language){

        if($language=='en' && $category=='yii'){

            $language = 'en-US';

        }

        return parent::translate($category, $message, $params, $language);

    }

}

and set config such module:




'i18n' => [

    ...

    'class' => \common\components\I18N::className(),

]



Seems like problem is gone, gonna debug a bit more.

Royal PITA

Many issues and questions posted for this problem. I do not believe Yii2 has solved it yet.

Perhaps I have failed to read/understand something. But time is up.

Why are there no english files (EG vendor/yiisoft/yii2/messages/en/yii.php) ?

Where do the defaults come from please?

Ah. They are embedded in the code of course.

So my config has


    'language'=>'en-US',

...

    'components' => [


        'i18n' => [

            'translations' => [

                'core' => [

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


                    // The base path for all translated messages. Defaults to '@app/messages'.

                    'basePath' => '/home/mehere/sites/www/messages',

                    'sourceLanguage' => 'en',

                    'fileMap' => [

                        'core' => 'core.php',

                    ],

                ],

                'shop' => [

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


                    // The base path for all translated messages. Defaults to '@app/messages'.

                    'basePath' => '/home/mehere/sites/www/messages',

                    'sourceLanguage' => 'en',

                    'fileMap' => [

                        'shop' => 'shop.php',

                    ],

                ],

                'chat' => [

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


                    // The base path for all translated messages. Defaults to '@app/messages'.

                    'basePath' => '/home/mehere/sites/www/messages',

                    'sourceLanguage' => 'en',

                    'fileMap' => [

                        'chat' => 'chat.php',

                    ],

                ],

/*

                // contact page is a problem child The CAPTCHA is firing this

The message file for category 'yii' does not exist: /home/mehere/sites/www/vendor/yiisoft/yii2/messages//yii.php Fallback file does not exist as well: /home/mehere/sites/www/vendor/yiisoft/yii2/messages//yii.php


    /home/mehere/sites/www/frontend/views/layouts/main.php:244

    /home/mehere/sites/www/frontend/controllers/SiteController.php:260


                'yii' => [

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

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

                    'sourceLanguage' => 'en',

                ],

*/

            ],

        ],



It’s a bit messy now because I have thrown out a third party package and am going back to basics.

I need to split those module configs out and get the alias back. But I think there is nothing wrong here.

To resolve this issue I took a language file for yii.php and removed all the translated strings. Placed it at /vendor/yiisoft/yii2/messages//yii.php and now I have no errors.

I think I will override PhpMessageSource:: loadMessages instead.

I fail to follow these in gory detail. None of the fixes seemed to work for me.