edk
(Edwardkoo)
July 18, 2012, 6:14am
1
My label code
in view
<?php echo $form->labelEx($model, Yii::t('translation','Apple')); ?>
in messages
<?php
return array (
'Apple' => '苹果',
);
?>
It shows ȋ�果 instead of 苹果
This is consistent with all browsers.
A bug? Any solution?
CeBe
July 22, 2012, 9:22pm
2
are all your files utf8 encoded?
abennouna
(Abennouna)
July 23, 2012, 9:47am
3
IMHO you should use
<?php echo $form->labelEx($model, 'Apple'); ?>
And, in your model’s attributeLabels():
return array(
…
'Apple' => Yii::t('translation','Apple'),
)
The behavior you have is because somewhere Yii won’t find the label for your translated string, so labelEx will use generateAttributeLabel and make the first character uppercase:
From http://www.yiiframework.com/doc/api/1.1/CModel#generateAttributeLabel-detail:
edk
(Edwardkoo)
July 24, 2012, 3:13am
4
I figured actually this is what i should do
<?php echo $form->labelEx($model, 'Apple', array('label' => Yii::t('translation','Apple'))); ?>
But this could probably be consider a bug if indeed my database field name of Apple is in Chinese word which will be written as
<?php echo $form->labelEx($model, '苹果'); ?>