can't translate the names in CHtml::listData() with Yii::t()

The problem is that I am building a multi language website and in this script:

dropDownList($model, ‘departmentId’, CHtml::listData( Departments::model()->findAll(), ‘id’, ‘name’), array(‘prompt’ => ‘Select a Department’));

The departments are displayed in english (because they are saved like that in the db) but I need to call the names in Yii::t(‘departments’, ‘name’) so that they can be shown in any language. But I can’t achieve that… It looks like the ‘name’ is hard coded in the CHtml::listData()

Is there a way to translate them without breaking the form structure created with the form widget and without creating db tables for every language…

I wonder if you could help me :)

dropDownList($model, ‘departmentId’, CHtml::listData( Departments::model()->findAll(), ‘id’, ‘name’), array(‘prompt’ => Yii::t(‘file name’, 'Select a Department’)));

I fixed it…

Hi could you tell me how you fixed the problem?

thanks in advance

Peter

I had the same problem and fixed it like this:


$listData = CHtml::listData(Model::model()->findAll(),'id','name');

$t_listData = array();

foreach($listData as $key => $item)

{

	$t_listData[$key]=Yii::t('translation',$item);

}

Try this http://www.yiiframework.com/wiki/66/i18n-for-your-model-in-just-1-line/

See ya!