# Translate model name when validation fails

**URL:** <https://www.ruby-forum.com/t/translate-model-name-when-validation-fails/162404>\
**Category:** Rails I18n\
**Created:** [March 9, 2009, 5:20pm UTC](https://www.ruby-forum.com/t/translate-model-name-when-validation-fails/162404 "2009-03-09T17:20:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [March 9, 2009, 5:20pm UTC](https://www.ruby-forum.com/t/translate-model-name-when-validation-fails/162404/1 "2009-03-09T17:20:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [March 13, 2009, 2:05pm UTC](https://www.ruby-forum.com/t/translate-model-name-when-validation-fails/162404/2 "2009-03-13T14:05:42Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [March 18, 2009, 3:59pm UTC](https://www.ruby-forum.com/t/translate-model-name-when-validation-fails/162404/3 "2009-03-18T15:59:07Z")

</div>

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!
