This project is archived and is in readonly mode.
Error_messages_for i18n not working as expected
-
Yaroslav Markin
- Assigned user set to Pratik
Could you please ask in http://groups.google.com/group/r... ?
Most of us got this stuff successfully working.
I think we should close for now
-
Stefan Achatz
I want to clarify the initial statement: ActiveRecord has two methods to get the model- and attribute-names i18n'ed: :human_name and :human_attribute_name both use klass.name.underscore to get the default. Latter is used by :full_messages, which is used in :error_messages_for.
So, why should :error_messages_for itself search with "model name" whereas every other code in the app uses "model_name"?
The locale would have to look like this: en: activerecord:
models: model name: "Thingy" # just to satisfy error_messages_for model_name: "Thingy" # used by the rest of the app attributes: model_name: column: "Something"My selfmade solution is similar to above suggestion: overwrite :error_messages_for and change the two lines in question to something like:
object_name = options[:object_name].to_s object_name = I18n.t(object_name, :default => object_name.gsub('_', ' '), :scope => [:activerecord, :models], :count => 1) -
Lukas Rieder
Hy,
I can confirm this strange behaviour. In my opinion the translation file should be clean and straightforward (no doubles with & without spaces). And I've learned the convention is that keys are underscored_names and not spaced names.
The attachment contains a diff that fixes the issue. (I've made the same correction like Stefan Achatz did)
Cheers, Lukas Rieder
-
José Valim
- State changed from new to resolved
This was fixed some time ago (yes!), you can see that this behavior cannot be reproduced on master.
