I am using Rails 3.1.1 and I would like to properly translate error messages for an ActiveModel
. I don't know if overwriting the i18n_scope
is the right way to solve my problem (or if there are other ways), but the official documentation says:
i18n_scope()
Returns the i18n_scope for the class. Overwrite if you want custom lookup.
... how should I overwtite the i18n_scope
?
At this time I am getting the following "alert":
# Note the 'activemodel' part
translation missing: de.activemodel.errors.models.my_class.attributes.message.blank
# I would like to "map" translations to 'de.activerecord.errors.messages.blank'
# as made for all other ActiveRecord classes in my application
My ActiveModel
class is like the following:
class MyClass
include ActiveModel::Conversion
include ActiveModel::Validations
include ActiveModel::Dirty
extend ActiveModel::Naming
extend ActiveModel::Translation
validates :name, :presence => true
...
end
It should be a class method, by analogy with AR code:
class MyClass
include ActiveModel ...
class << self
def i18n_scope
:activerecord
end
end
end