How can one change the messages that are shown in the flash for validates... to different languages? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Roman Hausner wrote:> How can one change the messages that are shown in the flash for > validates... to different languages?I am sure I can''t be the first one who wants to use the validation methods with error messages that are not in English? Is there a package for other languages or is it possible to override the built-in message texts somehow? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Roman Hausner wrote:> Roman Hausner wrote: > >> How can one change the messages that are shown in the flash for >> validates... to different languages? >> > > I am sure I can''t be the first one who wants to use the validation > methods with error messages that are not in English? > > Is there a package for other languages or is it possible to override the > built-in message texts somehow? > >Have a look here: http://wiki.rubyonrails.org/rails/pages/Internationalization and at the Globalize plugin. I haven''t yet use it (or any of the other options, but believe there''s a fairly active community, including a dedicated group: http://www.ruby-forum.com/forum/20 HTH --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On Nov 2, 2006, at 10:38 AM, Roman Hausner wrote:> Roman Hausner wrote: >> How can one change the messages that are shown in the flash for >> validates... to different languages? > > I am sure I can''t be the first one who wants to use the validation > methods with error messages that are not in English? > > Is there a package for other languages or is it possible to > override the > built-in message texts somehow?http://www.agilewebdevelopment.com/plugins/localization_simplified --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Roman Hausner wrote:> Is there a package for other languages or is it possible to override the > built-in message texts somehow?There are some docs for ruby on rails : http://api.rubyonrails.org/ For example validates_length_of (http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000814) suggests, for example, validates_length_of :last_name, :maximum=>30, :message=>"less than %d if you don''t mind" where :message can be redefined. The default error messages can also be added to, or changed, see the documentation for ActiveRecord::Errors http://api.rubyonrails.org/classes/ActiveRecord/Errors.html Regards, Chris -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
> http://www.agilewebdevelopment.com/plugins/localization_simplifiedThis simple localization is great, but it still uses my english model field names in validation error messages. Any way of overriding those? TIA Nick -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I don''t see a way of overriding the model field names. instead, just build your own error_messages_for method as a application helper. just have a look at the source of error_messages_for() in the API docs, its really simple. and instead of using the model field names, include the translated name in the validation message like : validates_length_of :last_name, :maximum=>30, :message=>"Last Name has to be less than %d" your own error_messages_for() in y<our ApplicationHelper could look something like this: e.g. (very simple example): def my_error_messages_for(object) message = String.New object.errors.each do |attr,msg| message << "#{msg}<br />\n" end message end (attr would be the model field name producing the error, msg would be the message set with :message in the validation) On 20 Feb., 17:39, Nic <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> >http://www.agilewebdevelopment.com/plugins/localization_simplified > > This simple localization is great, but it still uses my english model > field names in validation error messages. Any way of overriding those? > > TIA > Nick > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Roman Hausner wrote in post #160733:> How can one change the messages that are shown in the flash for > validates... to different languages?Hi , Me too come across a situation like getting validation messages in different languages .And done that successfully. Here is an example : /app/config/locales/models/en.yml # Models en: activerecord: errors: models: Modelname: blank: "FirstName cannot be blank!" Similarly create a file for other language with blank message in different lang. And in your model for eg you r having a validates_presence_of :fieldname1 By default validates_presence_of gives you the message as cant be blank which is now will be replaced by "FirstName cannot be blank!" (customised) -- Aruna -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Nic wrote in post #209083:>> http://www.agilewebdevelopment.com/plugins/localization_simplified > > This simple localization is great, but it still uses my english model > field names in validation error messages. Any way of overriding those?It is possible, but I don''t remember how off the top of my head. There''s been some discussion of this before, so if you search the list archives, you''ll probably find what you need.> > TIA > NickBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> This simple localization is great, but it still uses my english model> > field names in validation error messages. Any way of overriding those? > >elmer.yml activerecord: errors: models: rabbit: wabbit attributes: rescription: descwiption language: wanguage -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Radhames Brito wrote in post #956359:>> This simple localization is great, but it still uses my english model > >> > field names in validation error messages. Any way of overriding those? >> >> > > elmer.yml > > activerecord: > errors: > models: > rabbit: wabbit > attributes: > rescription: descwiption > language: wanguageGweat example! Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.