简体   繁体   中英

How to translate default error messages in rails?

This not worked for me when i tried to change error_messages_for messages in translation.yml file:

activerecord:
 errors:
  template:
    header:
      one:   "Oops error"
      other: "Many errors"
    body:    "There were problems:"

What can i do to translate "1 error prohibited this product from being saved:"? What file contain their text?

I believe you only need the activerecord: part if you're on Rails 2.x. The problem may be that your top level wasn't a language. As of Rails 3.x (which uses the separate dynamic_form plugin now to handle this), the defaults are:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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