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. -- Posted via http://www.ruby-forum.com/.
Hi Johan, you can append a :message=> parameter to any validation to override the default message. On 1/30/06, Johan Van Mol <johan.van.mol@gmail.com> wrote:> 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. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- -------------------------------------------------------------------- I am Mark Daggett and I approve this message.
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:>Hi Johan, >you can append a :message=> parameter to any validation to override >the default message. > > >On 1/30/06, Johan Van Mol <johan.van.mol@gmail.com> wrote: >> 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. >> >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > >-- >-------------------------------------------------------------------- >I am Mark Daggett and I approve this message. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsCheers! --Dave. -- Posted with http://DevLists.com. Sign up and save your time!
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? -- Posted via http://www.ruby-forum.com/.
Dave Teare 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. -- Posted via http://www.ruby-forum.com/.
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 : - translate the validation error message with the custom_validation_messages plugin - hide what cannot be translated with css => 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
Hi, On Tue, 31 Jan 2006 00:12:49 +0100 Johan Van Mol <johan.van.mol@gmail.com> wrote:> Dave Teare 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.Ruby-GetText-Package has already support this. See: http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html#Models -- .:% Masao Mutoh<mutoh@highway.ne.jp>
Hi, On Tue, 31 Jan 2006 00:06:25 +0100 Johan Van Mol <johan.van.mol@gmail.com> wrote:> 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?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 -- .:% Masao Mutoh<mutoh@highway.ne.jp>
Maybe Matching Threads
- no one cares about i18n (was [OT]: Asking questions on this list)
- Belgian Ruby on Rails Site
- Gettext not worked in firefox,but done well under IE
- ruby on rails international & BIRT integration?
- GetText: Works with en_GB and en_US, but doesn''t with de_DE!