|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Prevent(!) validation errors from being auto-translated?Hello everybody,
I love Globalize, it has made translating my application a snap. However, there is one question I have. When using customized validations that contain variables, like validates_exclusion_of :userlevel_id, :in => [1], :message => "You must be at least %d years if you have no accompanying adult" / ChildAge, :if => Proc.new { |u| u.age < ChildAge and u.adult_id.nil? } the error message gets translated twice, i.e. the translated string gets re-inserted into the globalize_translation table. This makes it impossible to use configuration values or global constants in these messages. (I don't want to change these config values in dozens of places, this is why I use constants). I think this is because Globalize automatically translates validation error messages. Can this behaviour be switched off? I'd rather insert a ".t" after every message, than having to cope with broken translations that confuse my translators. Thanks! Jens |
|
|
Re: Prevent(!) validation errors from being auto-translated?Hi Jens,
Try something like this: "You must be at least {age} years if you have no accompanying adult".t.gsub(/\{age}\/, ChildAge) Good luck! Juergen
|
|
|
Re: Prevent(!) validation errors from being auto-translated?
Hello, thanks... but this does not work, because the "gsub" happens "before" the translation. Globalize inserts "You must be at least 18 years old ..." into globalize_translations, and not "You must be at least %d years old ...". Now, when the variable changes all translations that contain it will become invalid. This is what I want to avoid (if all I wanted was this, I wouldn't need the global variables). Sigh ... ;( Thanks for your help though! Maybe you have another idea? Jens |
|
|
Re: Prevent(!) validation errors from being auto-translated?Works for me! Have you tried it really? My translations table shows
one entry only, which in your example is "You must be at least {age} years if you have no accompanying adult" Note: don't use the %d placeholders, but your own Good luck! Juergen On Oct 23, 2007, at 1:17 PM, JensB wrote: > > > ginger72 wrote: >> >> Hi Jens, >> >> Try something like this: >> "You must be at least {age} years if you have no accompanying >> adult".t.gsub(/\{age}\/, ChildAge) >> >> >> JensB wrote: >>> >>> Hello everybody, >>> >>> I love Globalize, it has made translating my application a snap. >>> However, >>> there is one question I have. When using customized validations that >>> contain variables, like >>> >>> validates_exclusion_of >>> :userlevel_id, :in => [1], >>> :message => "You must be at least %d years if you have no >>> accompanying >>> adult" / ChildAge, >>> :if => Proc.new { |u| u.age < ChildAge and u.adult_id.nil? } >>> >>> the error message gets translated twice, i.e. the translated >>> string gets >>> re-inserted into the globalize_translation table. I think this is >>> because >>> Globalize automatically translates validation error messages. Can >>> this >>> behaviour be switched off? >>> >> >> > > Hello, > > thanks... but this does not work, because the "gsub" happens > "before" the > translation. Globalize inserts "You must be at least 18 years > old ..." into > globalize_translations, and not "You must be at least %d years > old ...". > Now, when the variable changes all translations that contain it > will become > invalid. This is what I want to avoid (if all I wanted was this, I > wouldn't > need the global variables). > > Sigh ... ;( > > Thanks for your help though! Maybe you have another idea? > > Jens > > > > -- > View this message in context: http://www.nabble.com/Prevent%28%21% > 29-validation-errors-from-being-auto-translated-- > tf4677581s17045.html#a13372437 > Sent from the Globalize-rails.org mailing list archive at Nabble.com. > |
|
|
Re: Prevent(!) validation errors from being auto-translated?Ah, that's probably it. Do you have multiple languages in your translation table? Did you really mean ".t.gsub(..)", or just ".gsub(..)"? I'll check this tonight. Thanks! Jens |
| Free embeddable forum powered by Nabble | Forum Help |