Message Translation Help

HI guys,

I need some help configuring my app to use a message translation file,

In /protected/config/main.php i have

'sourceLanguage' => 'ja',

'language' => 'ja',

then under /protected/messages/ja i have app.php file which is the category for my translations.

This is not working, can somebody help me set this up?

i read but i can’t seem to figure out how to properly configure my app so that it can find the translated messages, only the core messages are translated.

I think the ‘sourceLanguage’ should not be ‘ja’.

If the ‘sourceLanguage’ equals to the ‘language’, then Yii will not do translation.

So, if your /protected/messages/ja/app.php has something like this …

return array (

  'Home' => 'ホーム',

  'Hello' => 'こんにちは',



then your ‘sourceLanguage’ should be ‘en_us’.


I think that virtually there’s no possible ‘sourceLanguage’ other than ‘en_us’, because the core files of Yii have the source messages written in English.

Am I wrong?


You can set as source language the language you want.

If the source is not the Yii one, all messages in components (like pager, datagrid and so on) will be translated.

The source language is the language the application is written in, so if you write in your application something like:

Y::t('main', 'Я люблю Россию');

The source language should be russian, that’s it.

Ah, OK.

I think I got it.

I have confirmed that the messages which belong to Yii core (i.e. the messages of ‘yii.php’ and ‘zii.php’ in ‘/framework/messages/’) will always be translated to ‘language’ no matter what ‘sourceLanguage’ you specified in the configuration.

So I should have said that no translation occurs in the application level if ‘language’ and ‘sourceLanguage’ are the same.

Am I right?

Thanks for your response, do you know if i correctly set up the app?

Assuming your source language is English, then /protected/config/main.php should contain …

return array(


	'sourceLanguage' => 'en_us',

	'language' => 'ja',


Then, you put the following line in /protected/messages/ja/app.php …

return array(


	'Hello World!' => 'こんにちは、世界のみなさん',


and in some view script you write …

<?php echo Yii::t('app', 'Hello World!'); ?>

If you get ‘こんにちは、世界のみなさん’ as a result, then it’s OK.

It worked, thanks for the help softark