Translated attributes in Rails error messages (Rails 2.3.2, I18N)

后端 未结 2 1792
遇见更好的自我
遇见更好的自我 2021-02-06 07:51

I have defined translated attributes and model names in the translation file and Modelname.human_attribute_name(...) returns the correctly translated attribute name, but the att

2条回答
  •  情书的邮戳
    2021-02-06 08:17

    Kudos to Ian, just wanted to add that in order to highlight the label in case of a failed validation you need to write it like this:

      <%= f.label "title", Model.human_attribute_name("title") %>

    For some reason, writing it just like:

      <%= f.label "title" %>

    doesn't display the translation.

提交回复
热议问题