Sha256: 32d2cfeda97491430ec05710f2a0fcdc740f20a9b2be43fbe33255eefcb2cd39

Contents?: true

Size: 495 Bytes

Versions: 3

Compression:

Stored size: 495 Bytes

Contents

module Agilibox::ModelI18n
  extend ActiveSupport::Concern

  def t(*args)
    self.class.t(*args)
  end

  def ts
    self.class.ts
  end

  def tv(attribute)
    key   = attribute
    value = public_send(attribute)
    t("#{key}.#{value}")
  end

  class_methods do
    def t(*args)
      if args.any?
        human_attribute_name(*args)
      else
        model_name.human
      end
    end

    def ts
      model_name.human(count: 2)
    end
  end # class_methods
end # Agilibox::ModelI18n

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
agilibox-1.0.8 app/models/concerns/agilibox/model_i18n.rb
agilibox-1.0.7 app/models/concerns/agilibox/model_i18n.rb
agilibox-1.0.6 app/models/concerns/agilibox/model_i18n.rb