How can I translate the ActiveRecord attribute name in Rails 3.2?

蹲街弑〆低调 提交于 2019-12-05 00:58:16

You can find the answer here http://guides.rubyonrails.org/i18n.html#translations-for-active-record-models

in your config/locale/(your_lang).yml

en: 
  activerecord:
    models:
      user: Dude
    attributes:
      user:
        first_name: "Name first"

change "en:" with the language symbol that you need to use

cheers

In Rails 5, after attributes, I had to namespace with my model's name in underscore. Like this:

pt-BR:
  activerecord:
    attributes:
      my_model_name_in_underscore: 
        attribute_name: 'String'  

Source: https://stackoverflow.com/a/5526812/1290457

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!