Yii Framework Forum: Translating labels - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Translating labels Rate Topic: -----

#1 User is offline   bas_vdl 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 215
  • Joined: 01-April 09

Posted 27 September 2009 - 01:13 PM

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'
        );
    }

This post has been edited by bas_vdl: 27 September 2009 - 01:17 PM

0

#2 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 27 September 2009 - 01:30 PM

The file should be in protected/messages/nl

/Tommy
Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
0

#3 User is offline   bas_vdl 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 215
  • Joined: 01-April 09

Posted 27 September 2009 - 01:33 PM

View Posttri, on 27 September 2009 - 01:30 PM, said:

The file should be in protected/messages/nl

/Tommy


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

but it's still not working
0

#4 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 27 September 2009 - 02:03 PM

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
Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
0

#5 User is offline   bas_vdl 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 215
  • Joined: 01-April 09

Posted 27 September 2009 - 02:10 PM

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>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users