I’m a belgian Rails user (Dutch is my native language). I wondered if
it is possible to translate error messages (generated by validators).
I know how to create my own error messages:
def method
content
rescue
logger.error(…)
flash[:notice] = 'My own error message"
redirect_to(…)
But where can I find the validator’s .rb files, so I can change them?
Johan.
Hi Johan,
you can append a :message=> parameter to any validation to override
the default message.
On 1/30/06, Johan Van M. [email protected] wrote:
redirect_to(…)
http://lists.rubyonrails.org/mailman/listinfo/rails
–
Thank you for your quick reply…
It works
Although I’m facing another problem now:
because my MySQL column names are in english, I get error messages which
mix english and dutch:
“english column name + dutch errormessage”
Could I use dutch column names? I guess table names HAVE to be english
(plurar form of the model’s class). What about columns?
You might find this useful: http://wiki.rubyonrails.org/rails/pages/
OverridingRailsMessagesInAnotherLanguage.
However, AFAIK, Rails still doesn’t have a good story when it comes to
i18n. I’m not sure how you would dynamically change the messages based
on the user’s locale.
On Monday, January 30, 2006, at 2:53 PM, M Daggett wrote:
I am Mark Daggett and I approve this message.
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
Cheers!
–Dave.
Johan
> I'm a belgian Rails user (Dutch is my native language). I
wondered if
> it is possible to translate error messages (generated by
validators).
My workaround is to :
=>
step 1: in the css:
#errorExplanation h2, div#errorExplanation p {
display:none; /* UGLY WORKAROUND, because the msg is in
English*/
}
step 2: install the plugin
http://estound.com/svn/rails/plugins/custom_validation_messages/
step 2: in the model, translate
validates_presence_of :first_name, :message => "[Le prénom est
manquant]"
(notice the ‘[’ and ‘]’: it’s the plugin convention to override
completely the error message, instead of appending)
Alain
Dave T. wrote:
You might find this useful: http://wiki.rubyonrails.org/rails/pages/
OverridingRailsMessagesInAnotherLanguage.
However, AFAIK, Rails still doesn’t have a good story when it comes to
i18n. I’m not sure how you would dynamically change the messages based
on the user’s locale.
Thanks,
That’s what I was looking for.
I also noticed this project: http://www.globalize-rails.org/wiki/
But I hoped to solve my problem without the use of a plugin.
Hi,
On Tue, 31 Jan 2006 00:12:49 +0100
Johan Van M. [email protected] wrote:
That’s what I was looking for.
I also noticed this project: http://www.globalize-rails.org/wiki/
But I hoped to solve my problem without the use of a plugin.
Ruby-GetText-Package has already support this.
See:
http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html#Models
Hi,
On Tue, 31 Jan 2006 00:06:25 +0100
Johan Van M. [email protected] wrote:
Could I use dutch column names? I guess table names HAVE to be english
(plurar form of the model’s class). What about columns?
Ruby-GetText-Package has already supported this.
See the screenshot page below, there have already exist dutch
translation.
You can find the column names are translated in dutch(compare screenshot
in English)
http://www.yotabanana.com/hiki/ruby-gettext-screenshot.html#Dutch
I think you need to try it ;).
There are 2 tutorials:
http://manuals.rubyonrails.com/read/chapter/105
http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html
Dear Masao M.,
Thank you for your help.
I will be using gettext in the future.
You wrote a wonderfull tutorial, and the screenshots are great too!
Johan.