Sha256: 10357fb3cd2b8097a4f2b2718661024f058018f3baea59c7a013575e9fbdb478

Contents?: true

Size: 620 Bytes

Versions: 5

Compression:

Stored size: 620 Bytes

Contents

module Spree
  module TranslatableResource
    extend ActiveSupport::Concern

    included do
      extend Mobility
      default_scope { i18n }

      def get_field_with_locale(locale, field_name, fallback: false)
        # method will return nil if no translation is present due to fallback: false setting
        public_send(field_name, locale: locale, fallback: fallback)
      end
    end

    class_methods do
      def translatable_fields
        const_get(:TRANSLATABLE_FIELDS)
      end

      def translation_table_alias
        "#{self::Translation.table_name}_#{Mobility.locale}"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_core-4.7.0 app/models/concerns/spree/translatable_resource.rb
spree_core-4.6.3 app/models/concerns/spree/translatable_resource.rb
spree_core-4.6.2 app/models/concerns/spree/translatable_resource.rb
spree_core-4.6.1 app/models/concerns/spree/translatable_resource.rb
spree_core-4.6.0 app/models/concerns/spree/translatable_resource.rb