Forum: Rails I18n Rails 3 Model attributes localization

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
465a674b0471ff8c76ae7597c94b075d?d=identicon&s=25 Kad K. (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
F3f9c2dee45279a8220cdad901be6f06?d=identicon&s=25 Andrés G. (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
B269a661e18295adcd1430e9716bd668?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.
465a674b0471ff8c76ae7597c94b075d?d=identicon&s=25 Kad K. (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.