Translating labels

i try to put my labels in a translation file. but it is not working at the moment. i followed the tutorial in this topic

instead of printing the translation its just printing the $message attribute of t().

the translation of yii core messages, like validation messages are working perfect.

i created a file labels.php in private_html/framework/messages/nl

main.php


'language'=>'nl'

labels.php


<?php

return array (

    'GroupId' => 'Groep'

);

User.php


    public function attributeLabels()

    {

        return array(

            'GroupId' => Yii::t('labels', 'GroupId'),

            'FirstName' => 'Voornaam',

            'LastName' => 'Achternaam',

            'Email' => 'E-mail',

            'Username' => 'Gebruikersnaam',

            'Password' => 'Wachtwoord',

            'ConfirmPassword' => 'Bevestig'

        );

    }

The file should be in protected/messages/nl

/Tommy

<_< path changed: protected\messages\nl\labels.php

but it’s still not working

Should work. How do you use the GroupId attribute in the view?

Try changing the display text in attributeLabels (you probably want to have a label like "Group Id"). Then change to the same text in left column of labels.php

/Tommy

view:


<?php echo CHtml::activeLabel($user, 'GroupId'); ?>

model:


    public function attributeLabels()

    {

        return array(

            'GroupId' => Yii::t('labels', 'GroupId'),

            'FirstName' => 'Voornaam',

labels.php:


<?php

return array (

    'GroupId' => 'Groep'

);

output:


<label for="User_GroupId">GroupId</label>