Transalate the column array values of the 'zii.widgets.grid.CGridView'

Hi All,

Here is my widget.

$this->widget('zii.widgets.grid.CGridView', array(










I have successfully transalted the column names into user languages. I would like to know that whether it is possible to transalate the column array values of the ‘zii.widgets.grid.CGridView’ (‘value’=>Yii::t($tr_file,’$data[\‘organisation\’][\‘attributes\’][\‘name\’]’),) into user languages?

I have tried this way, ‘value’=>Yii::t($tr_file,’$data[\‘organisation\’][\‘attributes\’][\‘name\’]’), but failed.

If it is possible, could you please show an example.

Thank you for your time.

First, why do you need to use a variable for selecting the translation group. Normally a string is used to identify the translation files for the actual group (e.g. ‘zii’). Then use the builtin Yii support for switching languages. (The files should reside in protected/messages/<language>).

[s]Second, you should be able to move the Yii::t() calls to the attributeLabels() method of the model

[/s]. Labels only, my bad.

[s]One option would be to call a method in the model, $data->someMethod(theAttribute).


[s]Have a look at the two suggestions I posted here.

[/s]. Never mind, I deleted that post. Probably should have had some sleep instead of posting in the Yii forum. Instead try this



… Instead try this




It worked, thank you very much for your help! :D