Translating Summary in CGridView

Hi all,

I’ve trying to translate the summary in the CGridView. There is a property to set the text “summaryText” but as I will be using a lot of these widgets I don’t want to set it on each widget.

I’ve looked the way it tries to translate there is this line in CBaseListView:


   $summaryText=Yii::t('zii','Displaying {start}-{end} of {count} result(s).');

But I don’t understand where is getting the translation from, in the zii framework folder the messages are empty.

What do you think?

Is it better to create a translation file (CPhpMessageSource) for the app and then on the "summaryText" property of CGridView just set like

Yii::t('app','Displaying {start}-{end} of {count} result(s).');

Or should I try to translate only those messgaes? If so could someone point me where to put the translated Zii messages. I don’t understand why is trying to translate from zii if there is nothing there.

Thank you all for your help.

My first guess is you should create translations in zii.php and put it in protected/messages/yourlanguage.

(not tested)


Thank You Tommy for your help.

You are completely right, actually the problem is another :

I have this website with content in english targeted to english users, but the persons who manage the site are portuguese so one module (admin) should be targeted to Portuguese(pt) users. If I set

in config "language"=>"en" then in the admin module translation will not occur since language = sourceLanguage.

Can I set the language for a specific module?

Am I doing something wrong? Or using this the wrong way?


If you’re still interested in an answer, have a look at the page on i18n: “One can configure target language in the application configuration, or change it dynamically before any internationalization occurs.”

It unfortunately lacks an example, but I can show you untested code for a i18n partly "de" and "pr". In the configuration file "config/main.php" it looks like

return array(

	'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',

	'name' => 'My app',

	'language' => 'de',

For an on the fly change of the application configuration, try:

ii::app()->language = 'pr';

I am new to Yii, just learning and exploring the framework.

Thanks Tuga for sharing a piece of code. That gave me the example on how to use summaryText property.

Cheers !