Boolean formatter translation

I think the "boolean" type text should be on the locale, my application in portuguese is showing "Yes" for the boolean field instead of a localized text.

I searched the source code, but found no way to translate it, maybe it should be added to the CLocale class?

hi

i have the same problem




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

	'id'=>'detalle-grid',

	'dataProvider'=>$detalle->search(),

	'columns'=>array(

                     	'idEgresoDetalle',

                     	'egreso.fecha',

                     	'cantidad',

                     	'tieneMovimiento:boolean:Tiene Movimiento', // this show Yes. how change Locale???


	),

));






I have exactly same problem as Horacio Segura. Tried Yii:t() with various class names (eg. CFormatter.my_cat) and tried to add translation to yii/framework/messages/pl/yii.php and zii.php. The only solution that worked was modifying CFormatter class itself but it awful way to me :)

It must be very simple to translate it only I miss something.

Please help :)

The problem was that i put it in without ’ :


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

	'dataProvider'=>$dataProvider,

	'columns'=>array(

		array('name'=>'active','value'=>Yii::t('boolean',$data->active),),

))); 

and should be




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

	'dataProvider'=>$dataProvider,

	'columns'=>array(

		array('name'=>'active','value'=>'Yii::t("boolean",$data->active)',),

))); 

Small bug but painful to notice for a Yii novice :)

Overall i found better solution:


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

	'dataProvider'=>$dataProvider,

	'columns'=>array(

		'activeLocalized',

)));

And in model class added one virtual property getter:


public function getActiveLocalized()

{

	return Yii::t('boolean', $this->active);

}

This is an old thread but I thought it needed an alternative for the records:

This article explains how to extend the CFormatter class to add i18N support

How to extend CFormatter, add i18n support to booleanFormat and use it in CDetailView

One advantage of this approach: It is compatible with the existing code in views and models (if you use extensions and such, you don’t need to change them).

Edit: you can also format the look by adding classes. For example, making "No" appear in red.

CLocalizedFormatter :rolleyes:

hello

Could you please give an exemple on how to use this new CLocalizedFormatter ?

I look for a way to display the translation of Yes / No for booleans in widgets.CDetailView