Language does not work

i have changed the messages structure from


  • en_us





– en_us

– he_il


– en_us

– he_il

now for some reason the Yii:t method does not translate the language. But the Yii::app()->translate does work and translates. I am sure i missed some setting so the Yii:t could work.

I did set the

Yii::app()->lang->basePath = Yii::app()->getBasePath() . '/messages/admin';

and it does work just not with the Yii:t method.

Any ideas?

What is Yii::app()->lang? And how did you call Yii::t()?

In the config file i added:

'lang' => array(

            'class' => 'CPhpMessageSource',


and i call Yii::t( 'category' , 'message');

Check YiiBase::t() signature. You need the 4th parameter to specify the message source ID since it is different from 'messages'.

I did try that with not luck, maybe i missing something i did the following:

Yii::t( $category, $message, $params, Yii::app()->getBasePath() . '/messages/admin');

naah, the fourth parameter should be message source ID, i.e., 'lang' in your case.

Not sure i follow the fourth parameter should be either for example 'en_us' or 'he_il' ?

just typing 'lang' in the forth did the trick…but why?

That's why API says: it should be the ID of the message source app component.

I am sure i am missing something. I never read anything about ID of a message source being 'lang' could you please explain a little more? I will appreciate that. I just don't want to move on without actually knowing why this worked like that.

See this: http://www.yiiframew…c/api/YiiBase#t

You said in your config, you defined a 'lang' message source. That's the application component ID I was talking about.