Forum: Rails I18n Rails 3 Model attributes localization

Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2010-09-24 19:24
(Received via mailing list)
I am trying to localize in Rails 3, and I don't understand the change
w Rails 2 ...

I wrote the following hierarchy :

en:
  model:
    user: User
    attributes:
      login: Login
      email: Email
      password: Password
      roles: Roles

and tried to use  in my view   I18n.t('user.roles')  to get the
localization of roles
but cannot find it :   translation missing: fr, user, roles

In rails 2 I had to stipulate activerecord:  should I do it also w
Rails 3 ?

thansk for your feedback
Adce10d7f1dbabcdab8f525a59cec32f?d=identicon&s=25 Andrés Gutiérrez (andresgutgon)
on 2010-09-24 19:31
(Received via mailing list)
2010/9/24 Erwin <yves_dufour@mac.com>

>      email: Email
>      password: Password
>      roles: Roles
>
> and tried to use  in my view   I18n.t('user.roles')  to get the
> localization of roles
> but cannot find it :   translation missing: fr, user, roles
>
I think you don't have to indent attributes in model. Try this:

en:
 model:
   user: User
 attributes:
   user:
     login: Login
     email: Email
     password: Password
     roles: Roles
4a551074ddba4460f95d011c47190d0e?d=identicon&s=25 Henrik --- (malesca)
on 2010-09-24 19:42
(Received via mailing list)
On Fri, Sep 24, 2010 at 19:22, Erwin <yves_dufour@mac.com> wrote:
>      email: Email
>      password: Password
>      roles: Roles
>
> and tried to use  in my view   I18n.t('user.roles')  to get the
> localization of roles
> but cannot find it :   translation missing: fr, user, roles
>
> In rails 2 I had to stipulate activerecord:  should I do it also w
> Rails 3 ?

Haven't used Rails 3 myself. Just try it and see, though. I would
guess you need to put the translation in
activerecord.attributes.user.roles.

Once you use that convention, you can do
User.human_attribute_name(:roles) instead of
I18n.t("activerecord.attributes.user.roles"). Assuming that didn't
change from Rails 2.
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2010-09-25 08:43
(Received via mailing list)
Thanks Henrik , no change in Rails 3
easier mgt of form labels however...
This topic is locked and can not be replied to.