For exmaple, edit config/locales/en.yml
en:
activerecord:
models:
user: User
attributes:
user:
name: Name
You can get
User.model_name.human # => User
User.human_attribute_name('name') # => Name
But how to write Rails 4.1 Enums I18n values ?
Try the enum_help gem. From its description:
Help ActiveRecord::Enum feature to work fine with I18n and simple_form.
I didn't find any specific pattern either, so I simply added:
en:
user_status:
active: Active
pending: Pending...
archived: Archived
to an arbitrary .yml file. Then in my views:
I18n.t :"user_status.#{user.status}"
cf. https://stackoverflow.com/a/23104850/797639
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With