Yii Framework Forum: Translation of form 'module.category' - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Translation of form 'module.category' Rate Topic: -----

#1 User is offline   galymzhan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 27-October 10
  • Location:Алматы

Posted 13 November 2010 - 10:00 AM

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).
2b || !2b that's the question
0

#2 User is offline   galymzhan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 27-October 10
  • Location:Алматы

Posted 16 November 2010 - 02:37 AM

Did someone meet this problem?
2b || !2b that's the question
0

#3 User is offline   andy_s 

  • Random Member Title
  • Yii
  • Group: Moderators
  • Posts: 1,526
  • Joined: 22-June 09
  • Location:Russia, Kostroma

Posted 16 November 2010 - 05:52 AM

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?
0

#4 User is offline   galymzhan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 27-October 10
  • Location:Алматы

Posted 16 November 2010 - 07:16 AM

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.yiiframew...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.
2b || !2b that's the question
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users