Rails Internationalization (I18n) in model validations: Possible or not?

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?

Thanks for your help!

38
задан meagar 22 April 2015 в 04:41
поделиться