Forum: Rails I18n Rails 3 Model attributes localization

Posted by 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
Posted by 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
Posted by 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.
Posted by 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...
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.