Sha256: e001d5e1a6f1ed6b55610ba2a0c869fc5f4c4d9016880a652283e4df2a75f748

Contents?: true

Size: 543 Bytes

Versions: 35

Compression:

Stored size: 543 Bytes

Contents

module Refine::Filter::Internationalized
  extend ActiveSupport::Concern

  included do
    class_attribute :i18n_scope, instance_writer: false
  end

  class_methods do
    def inherited(klass)
      klass.i18n_scope = klass.model_name.pluralize.underscore.tr("/", ".")
      super
    end
  end

  private

  def heading(field)
    t("#{field}.heading")
  end

  def options_for(field)
    t("#{field}.options").map { {id: _1.to_s, display: _2} }
  end

  def t(key, **options)
    I18n.t("#{i18n_scope}.fields.#{key}", **options)
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
refine-rails-2.10.0 app/models/refine/filter/internationalized.rb
refine-rails-2.9.14 app/models/refine/filter/internationalized.rb
refine-rails-2.9.13 app/models/refine/filter/internationalized.rb
refine-rails-2.9.12 app/models/refine/filter/internationalized.rb
refine-rails-2.9.11 app/models/refine/filter/internationalized.rb
refine-rails-2.9.10 app/models/refine/filter/internationalized.rb
refine-rails-2.9.9 app/models/refine/filter/internationalized.rb
refine-rails-2.9.8 app/models/refine/filter/internationalized.rb
refine-rails-2.9.7 app/models/refine/filter/internationalized.rb
refine-rails-2.9.6 app/models/refine/filter/internationalized.rb
refine-rails-2.9.5 app/models/refine/filter/internationalized.rb
refine-rails-2.9.4 app/models/refine/filter/internationalized.rb
refine-rails-2.9.3 app/models/refine/filter/internationalized.rb
refine-rails-2.9.2 app/models/refine/filter/internationalized.rb
refine-rails-2.9.1 app/models/refine/filter/internationalized.rb