Tôi đang sử dụng Rails 3.1.1 và tôi muốn dịch đúng thông báo lỗi cho số ActiveModel
. Tôi không biết nếu ghi đè i18n_scope
là đúng cách để giải quyết vấn đề của tôi (hoặc nếu có những cách khác), nhưng official documentation nói:Làm cách nào để xử lý bản dịch cho ActiveModel?
i18n_scope()
Trả về i18n_scope cho lớp. Ghi đè nếu bạn muốn tùy chỉnh tra cứu .
... Tôi nên overwtite i18n_scope
như thế nào?
Tại thời điểm này tôi nhận được một sau "cảnh báo":
# 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
lớp ActiveModel
của tôi là như sau:
class MyClass
include ActiveModel::Conversion
include ActiveModel::Validations
include ActiveModel::Dirty
extend ActiveModel::Naming
extend ActiveModel::Translation
validates :name, :presence => true
...
end
Hoàn hảo! Đã làm cho tôi. Chỉ vì tò mò, bạn có biết cấu trúc yml cho lớp mô hình activemodel không? –