thanks
but I am using the model_validators plugin:
there are some validations: like
validates_email_format_of :email
the default message is hardcoded englisch, so i would like to make it
I18n conform.
so I first tried a quick and dirty stuff and changed the default
message inside the model_validators plugin function
but this plugin is initialized at server startup. with the base_locale
en-US.
and now at runtime, i choose a different locale, but get the
translations in base_locale en-US
so i tried to override the default message with my own error_message.
I18n.t(:"validations.no_valid_email")
but if i only write
>>>>>>>>>>>>>
validates_email_format_of :email, :message =>
I18n.t(:"validations.no_valid_email")
<<<<<<<<<<<<<
i only get the en-US translation. not the translation depending on the
current_locale.
thats why i did the ugly stuff:
>>>>>>>>>>>>>
validates_email_format_of :email, :message =>
I18n.t(:"validations.no_valid_email", :locale => "en-US") , :if =>
Proc.new { |c| I18n.locale.to_s == "en" }
validates_email_format_of :email, :message =>
I18n.t(:"validations.no_valid_email", :locale => "de-DE") , :if =>
Proc.new { |c| I18n.locale.to_s == "de" }
<<<<<<<<<<<<
thanks,
florian
On Sep 30, 11:32 am, iain hecker <[EMAIL PROTECTED]> wrote:
> There is a nicer way! Translating ActiveRecord validation messages is
> built into Rails, so you don't have to make a I18n call at all.
>
> Have a look at my post in how to do
> this:http://iain.nl/2008/09/translating-activerecord/
> Chapter 5 and onwards are about validations.
>
> Good luck,
>
> Iain
>
> On Sep 30, 11:21 am, fwalter <[EMAIL PROTECTED]> wrote:
>
> > hi
>
> > I am using custom error messages. but I only get the translation of
> > the base_locale (en)
>
> > validates_presence_of :email, :message =>
> > I18n.t(:"validations.no_valid_email")
>
> > The way to get other translations looks like bullshit:
> > I tried to solve it that way:
>
> > validates_presence_of :email, :message =>
> > I18n.t(:"validations.no_valid_email", :locale => "en-US") , :if =>
> > Proc.new { |c| I18n.locale.to_s == "en" }
> > validates_presence_of :email, :message =>
> > I18n.t(:"validations.no_valid_email", :locale => "de-DE") , :if =>
> > Proc.new { |c| I18n.locale.to_s == "de" }
>
> > is there a nicer way to get the translations in correct language?
>
> > thanks for help
>
> > florian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"rails-i18n" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rails-i18n?hl=en
-~----------~----~----~----~------~----~------~--~---