rails 3保留默认错误消息的位置?

时间:2012-01-21 03:11:00

标签: ruby-on-rails

我需要翻译邮件而我找不到包含它们的文件?我已尝试从ruby guide尝试'5.1.3翻译Active Record error_messages_for Helper',但这不起作用

1 个答案:

答案 0 :(得分:2)

你应该在config / locales /中有一个en.yml(或whatever_locale.yml)。在其中,使用示例:

en:
  activerecord:
    errors:
      template:
        header:
          one:   "1 error prohibited this %{model} from being saved"
          other: "%{count} errors prohibited this %{model} from being saved"
        body:    "There were problems with the following fields:"

根据您的语言区域更改“en”。

以下是一个示例:

fr:
  activerecord:
    errors:
      format: "your message"
    errors:
      full_messages: "your message"
    errors:
      models:
        full_messages: "your message"
        TABLE_NAME_SINGULAR:
          blank:
              "\"%{attribute}\" is needed"
          attributes:
            ATTRIBUTE:
              blank:
                "Message"
              taken:
                "Message"

如果您在“config / locales”中创建一个新文件,我认为您必须重新启动Rails服务器......