Module: GettextI18nRails::ActiveRecord
- Defined in:
- lib/gettext_i18n_rails/active_record.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.
-
#human_name(*args) ⇒ Object
CarDealer -> _(‘car dealer’) method deprecated in Rails 3.1.
- #humanize_class_name(name) ⇒ Object
Instance Method Details
#gettext_translation_for_attribute_name(attribute) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/gettext_i18n_rails/active_record.rb', line 17 def gettext_translation_for_attribute_name(attribute) if attribute.to_s.ends_with?('_id') humanize_class_name(attribute) else "#{self}|#{attribute.to_s.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
3 4 5 |
# File 'lib/gettext_i18n_rails/active_record.rb', line 3 def human_attribute_name(attribute, *args) s_(gettext_translation_for_attribute_name(attribute)) end |
#human_name(*args) ⇒ Object
CarDealer -> _(‘car dealer’) method deprecated in Rails 3.1
9 10 11 |
# File 'lib/gettext_i18n_rails/active_record.rb', line 9 def human_name(*args) _(self.humanize_class_name(self.to_s)) end |
#humanize_class_name(name) ⇒ Object
13 14 15 |
# File 'lib/gettext_i18n_rails/active_record.rb', line 13 def humanize_class_name(name) name.underscore.humanize end |