Translation of form 'module.category'

I’ve a module called TranslationModule, which resides in protected/modules/translation folder. Snippet from config:




'import' => array(

        // Core

        'application.models.*',

        'application.components.*',


        // App

        'application.modules.user.models.*',

        'application.modules.user.components.*',

        'application.modules.translation.models.*',

        'application.modules.translation.components.*',

    ),

'modules' => array(

        'user',

        'translation',

    ),



Also, I’ve translation file: protected/modules/translation/messages/ru/translation.php

When I do


Yii::t('TranslationModule.translation', 'some string')

I get an error saying TranslationModule.php couldn’t be found for inclusion.

If I add to import section of config following line:


'application.modules.translation.*'

everything works fine. Is it mandatory? (This fact isn’t mentioned in docs but most likely I’m missing something).

Did someone meet this problem?

The reason is the next line in the CPhpMessageSource file (getMessageFile function):




$class=new ReflectionClass($moduleClass); // <<< Yii can't find TranslationModule class here.



I didn’t dive into sources, but I had a similar problem when I forgot a “Module” suffix in message category, so Yii couldn’t find a class. Modules’ translation is really not obvious in Yii. But can I ask what’s the benefit of using a module for translations?

I’m going to incapsulate all features in modules, so that modules can be reused in multiple sites. To do so, I need to distribute translations with module files. Also, I think mixing all translation files in ‘protected/messages’ is hard to manage, at least for me.

What I really don’t understand is how modules distributed through http://www.yiiframework.com/extensions/ are translated? Good example is yii-user extension which is translated into several languages. Translations reside in ‘messages’ folder, configuration needs to be altered to include module, his models and components, everything like I did.