Module: SmoothOperator::Translation

Included in:
Base
Defined in:
lib/smooth_operator/translation.rb

Instance Method Summary collapse

Instance Method Details

#human_attribute_name(attribute_key_name, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/smooth_operator/translation.rb', line 5

def human_attribute_name(attribute_key_name, options = {})
  no_translation = "-- no translation --"
  
  defaults = ["smooth_operator.attributes.#{name.underscore}.#{attribute_key_name}".to_sym]
  defaults << "activerecord.attributes.#{name.underscore}.#{attribute_key_name}".to_sym
  defaults << options[:default] if options[:default]
  defaults.flatten!
  defaults << no_translation
  options[:count] ||= 1
  
  I18n.translate(defaults.shift, options.merge(default: defaults))
end