Forum: Rails I18n Translate model name when validation fails

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.
Fernando P. (Guest)
on 2009-03-09 18:20
Let's say I want to submit a user. Currently if the user submission
fails, I get the name "user", but I would like to translate it into
other languages.

I can make the translation work for its attributes but not the model
name itself.

Thanks in advance.
Bassel S. (Guest)
on 2009-03-13 15:05
If you want to translate data and not just static content, I highly
recommend using Globalize2 as it has the best of both worlds.  You can
still use locale files for static content, but you can also use
translation tables.  I also wrote a small extension to it that I can
share if you'd like that lets you do things like en_name and sp_name and
so on to get the translated name you want.  I tried it out for my last
project, and I'm loving it.

Thanks,

Bassel
http://www.imustrant.com

Fernando P. wrote:
> Let's say I want to submit a user. Currently if the user submission
> fails, I get the name "user", but I would like to translate it into
> other languages.
>
> I can make the translation work for its attributes but not the model
> name itself.
>
> Thanks in advance.
Sjoerd A. (Guest)
on 2009-03-18 16:59
Fernando P. wrote:
> Let's say I want to submit a user. Currently if the user submission
> fails, I get the name "user", but I would like to translate it into
> other languages.
>
> I can make the translation work for its attributes but not the model
> name itself.
>
> Thanks in advance.

You can translate model names in a similar way you translate its
attributes:

<code><pre>
en:
  activerecord:
    models:
      user: Gebruiker
    attributes:
      user:
        login: gebruikersnaam
</pre></code>

Hope this works for you!
This topic is locked and can not be replied to.