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.13.3 app/models/refine/filter/internationalized.rb
refine-rails-2.13.2 app/models/refine/filter/internationalized.rb
refine-rails-2.13.1 app/models/refine/filter/internationalized.rb
refine-rails-2.13.0 app/models/refine/filter/internationalized.rb
refine-rails-2.12.2 app/models/refine/filter/internationalized.rb
refine-rails-2.12.1 app/models/refine/filter/internationalized.rb
refine-rails-2.12.0 app/models/refine/filter/internationalized.rb
refine-rails-2.11.12 app/models/refine/filter/internationalized.rb
refine-rails-2.11.11 app/models/refine/filter/internationalized.rb
refine-rails-2.11.10 app/models/refine/filter/internationalized.rb
refine-rails-2.11.9 app/models/refine/filter/internationalized.rb
refine-rails-2.11.8 app/models/refine/filter/internationalized.rb
refine-rails-2.11.6 app/models/refine/filter/internationalized.rb
refine-rails-2.11.5 app/models/refine/filter/internationalized.rb
refine-rails-2.11.4 app/models/refine/filter/internationalized.rb
refine-rails-2.11.3 app/models/refine/filter/internationalized.rb
refine-rails-2.11.2 app/models/refine/filter/internationalized.rb
refine-rails-2.11.1 app/models/refine/filter/internationalized.rb
refine-rails-2.11.0 app/models/refine/filter/internationalized.rb
refine-rails-2.10.1 app/models/refine/filter/internationalized.rb