我正在使用Rails 3.1.1,我想正确翻译ActiveModel的错误消息.我不知道如果覆盖i18n_scope是解决我的问题的正确方法(或者有其他方法),但是
official documentation说:
i18n_scope()
Returns the i18n_scope for the class. Overwrite if you want custom
lookup.
…我应该如何超越i18n_scope?
在这个时候我得到以下“警报”:
# 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
我的ActiveModel类如下所示:
class MyClass include ActiveModel::Conversion include ActiveModel::Validations include ActiveModel::Dirty extend ActiveModel::Naming extend ActiveModel::Translation validates :name,:presence => true ... end