Sha256: 53c59801a9036e5cb5ae6f62a5227a563f3ba5622c5e9ed144b7203269b18b64

Contents?: true

Size: 616 Bytes

Versions: 26

Compression:

Stored size: 616 Bytes

Contents

class ActiveRecord::Base
  # CarDealer.sales_count -> s_('CarDealer|Sales count') -> 'Sales count' if no translation was found
  def self.human_attribute_name(attribute, *args)
    s_(gettext_translation_for_attribute_name(attribute))
  end

  # CarDealer -> _('car dealer')
  def self.human_name(*args)
    _(self.human_name_without_translation)
  end

  def self.human_name_without_translation
    self.to_s.underscore.gsub('_',' ')
  end

  private

  def self.gettext_translation_for_attribute_name(attribute)
    "#{self}|#{attribute.to_s.split('.').map! {|a| a.gsub('_',' ').capitalize }.join('|')}"
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
zena-1.2.8 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb
zena-1.2.7 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb
zena-1.2.6 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb
zena-1.2.5 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb
zena-1.2.4 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb
zena-1.2.3 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb
zena-1.2.2 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb
zena-1.2.1 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb
zena-1.2.0 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb
gettext_i18n_rails-0.3.5 lib/gettext_i18n_rails/active_record.rb
gettext_i18n_rails-0.3.4 lib/gettext_i18n_rails/active_record.rb
gettext_i18n_rails-0.3.3 lib/gettext_i18n_rails/active_record.rb
gettext_i18n_rails-0.3.2 lib/gettext_i18n_rails/active_record.rb
gettext_i18n_rails-0.3.1 lib/gettext_i18n_rails/active_record.rb
zena-1.1.3 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb
zena-1.1.2 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb
gettext_i18n_rails-0.3.0 lib/gettext_i18n_rails/active_record.rb
zena-1.1.1 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb
zena-1.1.0 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb
zena-1.0.0 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb