method
human_attribute_name
v3.2.1 -
Show latest stable
- Class:
ActiveModel::Translation
human_attribute_name(attribute, options = {})public
Transforms attribute names into a more human format, such as “First name” instead of “first_name”.
Person.human_attribute_name("first_name") # => "First name"
Specify options with additional translating options.
3Notes
Default values
For common attributes in several models, you can set a default human name like this:
==== de.yml
de:
attributes:
bez: Bezeichnung
abk: Abkürzung
Works also with Mongoid
What works for Active Record, also works for Mongoid:
de:
mongoid:
attributes:
picture:
explanation: Description
Nested i18n attributes
If you want to use nested attributes in a i18n file (like person :has_many => :addresses), write:
en:
activerecord:
attributes:
person:
name:
"person/addresses":
street: "Street name"
"person/phones":
area: "Area code"
number: Number