简体   繁体   English

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

[英]Where rails 3 keeps default error messages?

I need to translate messages and i can't find a file that contained them? 我需要翻译消息,我找不到包含它们的文件? I've tried '5.1.3 Translations for the Active Record error_messages_for Helper' from ruby guide but that didn't work 我从ruby指南尝试过“5.1.3翻译Active Record error_messages_for Helper”,但是没有用

You should have a en.yml (or whatever_locale.yml) in config/locales/. 你应该在config / locales /中有一个en.yml(或whatever_locale.yml)。 In it, use the example: 在其中,使用示例:

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:"

Change "en" by your locale. 根据您的语言环境更改“en”。

Here is a sample: 这是一个示例:

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"

If you create a new file in "config/locales", I think you have to restart Rails server... 如果您在“config / locales”中创建一个新文件,我认为您必须重新启动Rails服务器...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM