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 the suggestion - unfortunately, it doesn't change the
outcome...
Perhaps you should just have the validation routine generate the
translation key (in other words, leave off I18n.t), then apply the
translation in the view layer.
since that is the default behavior i assumed ‘please_select_whatever’ is a dynamic value taken from the model, if its not the case
everything should word without the need of doing the translation in the model
Nope, this doesn't work. I suspect it's still the same problem: it seems
not possible to have translations in models (since they only get loaded
once).
It may work for the default "keys" (for "validates_presence_of :name"
the key would be "blank"), but not the custom ones.
We've done it in the Kete app (http://github.com/kete/kete), but I
can't recall the trick. I'll check with the guy that did it an see if
he has an answer for you...
If you're using a Rails gem, or Rails is vendored, and you don't want
it to be lost when upgrading, put it in an all_extensions.rb
initializer, like I did here: