module ActiveModel::Translation

def human_attribute_name(attribute, options = {})

Specify +options+ with additional translating options.

Person.human_attribute_name("first_name") # => "First name"

instead of "first_name".
Transforms attribute names into a more human format, such as "First name"
def human_attribute_name(attribute, options = {})
  defaults = lookup_ancestors.map do |klass|
    [:"#{self.i18n_scope}.attributes.#{klass.model_name.i18n_key}.#{attribute}",
     :"#{self.i18n_scope}.attributes.#{klass.model_name.i18n_key.to_s.tr('.', '/')}.#{attribute}"]
  end.flatten
  defaults << :"attributes.#{attribute}"
  defaults << options.delete(:default) if options[:default]
  defaults << attribute.to_s.humanize
  options.reverse_merge! :count => 1, :default => defaults
  I18n.translate(defaults.shift, options)
end

def human_name(*args)

Model.human_name is deprecated. Use Model.model_name.human instead.
def human_name(*args)
  ActiveSupport::Deprecation.warn("human_name has been deprecated, please use model_name.human instead", caller[0,5])
  model_name.human(*args)
end

def i18n_scope

Returns the i18n_scope for the class. Overwrite if you want custom lookup.
def i18n_scope
  :activemodel
end

def lookup_ancestors

ActiveModel::Translation#human_attribute_name.
ActiveModel::Errors#full_messages and
method, which is used in ActiveModel::Name#human,
When localizing a string, it goes through the lookup returned by this
def lookup_ancestors
  self.ancestors.select { |x| x.respond_to?(:model_name) }
end