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