Module: ActiveModel::Translation
- Included in:
- GettextI18nRails::ActiveRecord
- Defined in:
- lib/gettext_i18n_rails/active_model.rb
Instance Method Summary collapse
- #gettext_translation_for_attribute_name(attribute) ⇒ Object
-
#human_attribute_name(attribute, *args) ⇒ Object
CarDealer.sales_count -> s_(‘CarDealer|Sales count’) -> ‘Sales count’ if no translation was found.
- #humanize_class_name(name = nil) ⇒ Object
Instance Method Details
#gettext_translation_for_attribute_name(attribute) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/gettext_i18n_rails/active_model.rb', line 14 def gettext_translation_for_attribute_name(attribute) attribute = attribute.to_s if attribute.ends_with?('_id') humanize_class_name(attribute) else "#{self}|#{attribute.split('.').map! {|a| a.humanize }.join('|')}" end end |
#human_attribute_name(attribute, *args) ⇒ Object
CarDealer.sales_count -> s_(‘CarDealer|Sales count’) -> ‘Sales count’ if no translation was found
10 11 12 |
# File 'lib/gettext_i18n_rails/active_model.rb', line 10 def human_attribute_name(attribute, *args) s_(gettext_translation_for_attribute_name(attribute)) end |
#humanize_class_name(name = nil) ⇒ Object
23 24 25 26 |
# File 'lib/gettext_i18n_rails/active_model.rb', line 23 def humanize_class_name(name=nil) name ||= self.to_s name.underscore.humanize end |