【问题标题】:Rails 3 ActiveRecord LocalizationRails 3 ActiveRecord 本地化
【发布时间】:2012-03-02 12:02:06
【问题描述】:

我正在尝试本地化 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 activerecord internationalization


【解决方案1】:

你的 uk.yml 中有 active_record,而不是 activerecord

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-01
    • 2013-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-15
    • 1970-01-01
    相关资源
    最近更新 更多