简体   繁体   中英

How to translate model names in rails for error messages in locale yml file?

I want to translate the name of the model in the rails auto-generated error messages.

I get the following view error in my rails application when I try to create a new account for a user.

AccountSmall is not valid

This is correct, because the name for a new account should be present.

How can I now translate the AccountSmall name via my yml locale?

I tried this with no luck:

de:
  # ...
  activerecord:
    models:
      AccountSmall: "Konto"

Many thanks in advance!

Instead of AccountSmall use account_small as the key in your locale like so:

de:
  activerecord:
    models:
      account_small: "Konto"

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