Translate model name when validation fails


#1

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.


#2

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.


#3

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:


en:
activerecord:
models:
user: Gebruiker
attributes:
user:
login: gebruikersnaam

Hope this works for you!