Forum: Rails I18n Translate model name when validation fails

Posted by Fernando Perez (fernando)
on 2009-03-09 17: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.
Posted by Bassel Samman (mercedes6s)
on 2009-03-13 14: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 Perez 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.
Posted by Sjoerd Andringa (s-andringa)
on 2009-03-18 15:59
Fernando Perez 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!
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.