Swissdude
Swissdude

Reputation: 3556

yii activeform label translation from different translation-file

I need to translate a label of an active form without changing the model.

This:

$form->label($model, 'myField', array('class' => 'title'))

Takes the translation by default from the translation.php in the protected/messages/lang/ folder.

Now I want the label to take the translation from another file (without changing the model). How would I do that? The docs are a little vague on what kind of variables I can pass to the label...

Upvotes: 1

Views: 856

Answers (1)

Goodnickoff
Goodnickoff

Reputation: 2267

You can specify label in the $htmlOptions array: http://www.yiiframework.com/doc/api/1.1/CHtml#activeLabel-detail

$form->label(
  $model, 
  'myField', 
  array('class' => 'title', 'label' => Yii::t('myCategory', 'Field label'))
)

Yii::t() method translates the given message from source language to target language. You can read more information about internationalization here:

http://www.yiiframework.com/doc/api/1.1/YiiBase#t-detail http://www.yiiframework.com/doc/guide/1.1/en/topics.i18n

Upvotes: 1

Related Questions