我正在尝试本地化 ActiveRecord 错误消息(乌克兰语)。
首先,我设置了 application.rb 文件:config.i18n.default_locale = :uk
其次,我创建了一个文件 /config/locales/uk.yml
uk.yml中有这样的内容:
uk:
active_record:
errors:
messages:
empty: "<some Ukrainian text>"
blank: "<some Ukrainian text>"
此外,我知道为了翻译错误消息,Rails 将使用以下翻译顺序:
activerecord.errors.models.user.attributes.name.blank
activerecord.errors.models.user.blank
activerecord.errors.messages.blank
errors.attributes.name.blank
errors.messages.blank
但是当我执行某个操作时,我收到消息:
缺少电子邮件翻译:uk.activerecord.errors.models.user.attributes.email.blank
我的问题是为什么 l18n 不在路径 activerecord.errors.messages.blank 搜索翻译?
谢谢。
最佳答案
你的 uk.yml 中有 active_record
,而不是 activerecord
关于ruby-on-rails - Rails 3 ActiveRecord 本地化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9532966/