# Globalize and model error messages

**URL:** <https://www.ruby-forum.com/t/globalize-and-model-error-messages/70831>\
**Category:** Rails I18n\
**Created:** [October 3, 2006, 10:12am UTC](https://www.ruby-forum.com/t/globalize-and-model-error-messages/70831 "2006-10-03T10:12:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicolas\_NoSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b19c9b/32.png) [@Nicolas\_NoSSSS](https://www.ruby-forum.com/u/Nicolas_NoSSSS)\
**Post date:** [October 3, 2006, 10:12am UTC](https://www.ruby-forum.com/t/globalize-and-model-error-messages/70831/1 "2006-10-03T10:12:25Z")

</div>

Hi !  
I have a probably stupid question about i18n. I started to work with  
ruby-gettext, as it allows me to translate field names in model  
validation messages, and thus use error\_messages\_for helpers. It first  
worked well, but I now have some problems with it (when trying to  
internationalize a hierarchy of models, with some attributes wich  
doesn’t exists in the database). Gettext is nice, but seems to me more  
like a ‘unix’ solution than a rails solution, so I’m open to change…

My question is here : a lot of people seems to use globalize or other  
i18n plugins that, if I believe what I read, don’t support translating  
models field names, table names, and error messages. So, how do you use  
rails validation in yout multilingual websites. Is there another  
not\_too\_complicated way to use rails validation, which is a great system  
?

Thanx in advance,

Nicolas

---

<div class="post-metadata">

**Author:** ![Nicolas\_NoSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b19c9b/32.png) [@Nicolas\_NoSSSS](https://www.ruby-forum.com/u/Nicolas_NoSSSS)\
**Post date:** [October 3, 2006, 7:06pm UTC](https://www.ruby-forum.com/t/globalize-and-model-error-messages/70831/2 "2006-10-03T19:06:22Z")

</div>

On Tue, 3 Oct 2006 10:12:25 +0200  
“Nicolas Noe$(D+1” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> i18n plugins that, if I believe what I read, don’t support translating  
> models field names, table names, and error messages. So, how do you use  
> rails validation in yout multilingual websites. Is there another  
> not\_too\_complicated way to use rails validation, which is a great system  
> ?

I don’t think to detain you leave from gettext.  
But I have to say, ruby-gettext has a solution to translate the  
attributes  
which doesn’t exists in the database.

[http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html#Translate+the+attributes+which+doesn't+exist+in+your+Database](http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html#Translate+the+attributes+which+doesn%27t+exist+in+your+Database)

---

<div class="post-metadata">

**Author:** ![Nicolas\_NoSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b19c9b/32.png) [@Nicolas\_NoSSSS](https://www.ruby-forum.com/u/Nicolas_NoSSSS)\
**Post date:** [October 4, 2006, 2:23pm UTC](https://www.ruby-forum.com/t/globalize-and-model-error-messages/70831/3 "2006-10-04T14:23:11Z")

</div>

Masao M. wrote:

> On Tue, 3 Oct 2006 10:12:25 +0200  
> “Nicolas Noe$(D+1” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > i18n plugins that, if I believe what I read, don’t support translating  
> > models field names, table names, and error messages. So, how do you use  
> > rails validation in yout multilingual websites. Is there another  
> > not\_too\_complicated way to use rails validation, which is a great system  
> > ?
> 
> I don’t think to detain you leave from gettext.  
> But I have to say, ruby-gettext has a solution to translate the  
> attributes  
> which doesn’t exists in the database.
> 
> [http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html#Translate+the+attributes+which+doesn't+exist+in+your+Database](http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html#Translate+the+attributes+which+doesn%27t+exist+in+your+Database)

Thanks !

Yeah, I already use gettext for that, and that works pretty well.  
However, I had problems to use it with a hierarchy of Models (it seems  
to extract direct childs of ActiveRecord::Base, but not descendents of  
descendents of ActiveRecord::Base).  
As I’m new to rails and have an applic to develop and maintain, I was  
afraid that maybe gettext could cause other problems later and impeach  
me of using all rails features…For the moment it’s ok, I found another  
way to solve my problem.

---

<div class="post-metadata">

**Author:** ![Nicolas\_NoSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b19c9b/32.png) [@Nicolas\_NoSSSS](https://www.ruby-forum.com/u/Nicolas_NoSSSS)\
**Post date:** [October 16, 2006, 6:56pm UTC](https://www.ruby-forum.com/t/globalize-and-model-error-messages/70831/4 "2006-10-16T18:56:31Z")

</div>

Nicolas NoÃ© wrote:

[…]

> As I’m new to rails and have an applic to develop and maintain, I was  
> afraid that maybe gettext could cause other problems later and impeach  
> me of using all rails features…For the moment it’s ok, I found another  
> way to solve my problem.

How have You solved that problem? Have You found method to translate  
fields and class names in Globalize?

---

<div class="post-metadata">

**Author:** ![Nicolas\_NoSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b19c9b/32.png) [@Nicolas\_NoSSSS](https://www.ruby-forum.com/u/Nicolas_NoSSSS)\
**Post date:** [October 19, 2006, 9:26am UTC](https://www.ruby-forum.com/t/globalize-and-model-error-messages/70831/5 "2006-10-19T09:26:20Z")

</div>

bal wrote:

> Nicolas NoÃ© wrote:
> 
> […]
> 
> > As I’m new to rails and have an applic to develop and maintain, I was  
> > afraid that maybe gettext could cause other problems later and impeach  
> > me of using all rails features…For the moment it’s ok, I found another  
> > way to solve my problem.
> 
> How have You solved that problem? Have You found method to translate  
> fields and class names in Globalize?

No, I continued to used gettext…

---

<div class="post-metadata">

**Author:** ![Nicolas\_NoSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b19c9b/32.png) [@Nicolas\_NoSSSS](https://www.ruby-forum.com/u/Nicolas_NoSSSS)\
**Post date:** [October 19, 2006, 1:28pm UTC](https://www.ruby-forum.com/t/globalize-and-model-error-messages/70831/6 "2006-10-19T13:28:42Z")

</div>

I’m getting into this a bit late, but Globalize was designed to handle  
this. Globalize automatically tries to translate ActiveRecord  
validation messages, so if you trigger a validation error, that  
message should show up in the globalize\_translations table and be  
available for translation. Because Globalize’s string substitution  
isn’t quite as sophisticated as we want it to be, it can’t translate  
field names separately from the validation message. This means you  
have to translate all combination of field name/validation type. In  
many apps this isn’t that big a problem, but if it is in your case,  
let us know. This would be a good thing to write up a ticket for.

– Josh
