On Dec 15, 2010, at 6:13 AM, Tom Ha wrote:
> Hi there,
>
> I have the following validation in a model:
>
> validates_inclusion_of :whatever, :in => [true, false], :message =>
> I18n.t('please_select_whatever')
>
> It seems that the translation does not work in production mode: in all
> languages it's always the english translation that gets diplayed
> (probably because I set english as the default locale in my app...?).
>
> So I am assuming that we can't translate validations in models, because
> models get loaded only once - when the server is booted (and then, the
> default locale would be applied).
>
> Am I right? If yes, how would you solve this problem?
http://guides.rubyonrails.org/i18n.html#translations-for-active-record-models
In particular see the table in section "5.1.2 Error Message Interpolation"
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment