你如何为另一个语言环境提供自定义错误消息? (动作邮件)

时间:2012-11-20 16:13:34

标签: ruby-on-rails ruby internationalization actionmailer

工作 [当区域设置为en时有效]当我点击“发送”按钮时,会显示错误消息name is blankemail is blank等(当字段为空时)这很好。输出如下:

3 errors prohibited this message from being sent:

Email can't be blank
Email is invalid
Subject can't be blank

无法正常工作但[当区域设置为es时不起作用]当我点击“发送”按钮时,它会显示错误消息,如下所示:

3 errors prohibited this message from being sent:

Email translation missing: es.activemodel.errors.models.message.attributes.email.blank
Email translation missing: es.activemodel.errors.models.message.attributes.email.invalid
Subject translation missing: es.activemodel.errors.models.message.attributes.subject.blank

问题所以如何让这个翻译工作需要帮助,时间不多了。

感谢。

1 个答案:

答案 0 :(得分:2)

您的es语言环境文件中是否设置了es.activemodel.errors.models.message.attributes.email.blank值?

es.yml中的这个:

es:
  activemodel:
    errors:
      models:
        message:
          attributes:
            email:
              blank: "I don't speak spanish I can't give an example ... Shame on me!"