5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/simple_enum/translation.rb', line 5
def human_enum_name(enum, key, options = {})
return '' unless key.present?
defaults = lookup_ancestors.map do |klass|
:"#{self.i18n_scope}.enums.#{klass.model_name.i18n_key}.#{enum}.#{key}"
end
defaults << :"enums.#{self.model_name.i18n_key}.#{enum}.#{key}"
defaults << :"enums.#{enum}.#{key}"
defaults << options.delete(:default) if options[:default]
defaults << key.to_s.humanize
options.reverse_merge! count: 1, default: defaults
I18n.translate(defaults.shift, options)
end
|