Sha256: a0a2ed9e9e32b84adcd3402df906dd84c4f3d00f20a87797ec08bbea27ccf7ec

Contents?: true

Size: 827 Bytes

Versions: 8

Compression:

Stored size: 827 Bytes

Contents

require 'i18n'
require 'active_support/core_ext/array/extract_options'
require 'spree/i18n/base'

module Spree
  extend ActionView::Helpers::TranslationHelper

  class << self
    # Add spree namespace and delegate to Rails TranslationHelper for some nice
    # extra functionality. e.g return reasonable strings for missing translations
    def translate(*args)
      @virtual_path = virtual_path

      options = args.extract_options!
      options[:scope] = [*options[:scope]].unshift(:spree)
      args << options
      super(*args)
    end

    alias_method :t, :translate

    def context
      Spree::ViewContext.context
    end

    def virtual_path
      if context
        path = context.instance_variable_get("@virtual_path")

        if path
          path.gsub(/spree/, '')
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
spree_core-2.1.3 lib/spree/i18n.rb
spree_core-2.0.7 lib/spree/i18n.rb
spree_core-2.1.2 lib/spree/i18n.rb
spree_core-2.0.6 lib/spree/i18n.rb
spree_core-2.1.1 lib/spree/i18n.rb
spree_core-2.0.5 lib/spree/i18n.rb
spree_core-2.1.0 lib/spree/i18n.rb
spree_core-2.0.4 lib/spree/i18n.rb