Module: ActiveModel::Translation

### Home Classes Methods

### In Files

- lib/gettext_i18n_rails/active_model/translation.rb

### Methods

- #gettext_translation_for_attribute_name
- #human_attribute_name
- #humanize_class_name
- #inheritance_tree_root

### Class/Module Index

Quicksearch

- GettextI18nRails
- GettextI18nRails::Backend
- GettextI18nRails::BaseParser
- GettextI18nRails::GettextHooks
- GettextI18nRails::HamlParser
- GettextI18nRails::HtmlSafeTranslations
- GettextI18nRails::ModelAttributesFinder
- GettextI18nRails::Railtie
- GettextI18nRails::SlimParser
- RubyGettextExtractor
- RubyGettextExtractor::Extractor18
- RubyGettextExtractor::Extractor19
- RubyGettextExtractor::ExtractorMethods
- ActionController
- ActionController::Base
- ActiveModel
- ActiveModel::Translation
- ActiveRecord
- ActiveRecord::Base
- I18n
- I18n::Config
- Object
- String

No matching classes.

# ActiveModel::Translation

### Public Instance Methods

gettext_translation_for_attribute_name(attribute) click to toggle source

    # File lib/gettext_i18n_rails/active_model/translation.rb, line 8
    def gettext_translation_for_attribute_name(attribute)
      attribute = attribute.to_s
      if attribute.ends_with?('_id')
        humanize_class_name(attribute)
      else
        "#{inheritance_tree_root(self)}|#{attribute.split('.').map! {|a| a.humanize }.join('|')}"
      end
    end

human_attribute_name(attribute, *args) click to toggle source

CarDealer.sales_count -> s_('CarDealer|Sales count') -> 'Sales count' if no translation was found

    # File lib/gettext_i18n_rails/active_model/translation.rb, line 4
    def human_attribute_name(attribute, *args)
      s_(gettext_translation_for_attribute_name(attribute))
    end

humanize_class_name(name=nil) click to toggle source

    # File lib/gettext_i18n_rails/active_model/translation.rb, line 23
    def humanize_class_name(name=nil)
      name ||= self.to_s
      name.underscore.humanize
    end

inheritance_tree_root(aclass) click to toggle source

    # File lib/gettext_i18n_rails/active_model/translation.rb, line 17
    def inheritance_tree_root(aclass)
      return aclass unless aclass.respond_to?(:base_class)
      base = aclass.base_class
      base.superclass.abstract_class? ? base.superclass : base
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.