Sha256: a9c7ee7528acef613cb07c69c3252031de5d4650355824f0835192cce6516f12

Contents?: true

Size: 985 Bytes

Versions: 54

Compression:

Stored size: 985 Bytes

Contents

module Locomotive
  module Steam
    module Liquid
      module Drops
        class I18nBase < Base

          def initialize(source)
            # puts "creating #{self.class.name} drop for #{source.class.name}(#{source.object_id.inspect})"
            decorated = source if source.respond_to?(:__locale__)
            decorated ||= Locomotive::Steam::Decorators::I18nDecorator.new(source)
            super(decorated)
          end

          def context=(context)
            if locale = context.registers[:locale]
              @_source.__locale__ = locale
            end

            @_source.__default_locale__ = context.registers[:site].try(:default_locale)

            super
          end

          private

          def _change_locale(locale)
            @_source.__locale__ = locale
          end

          def _change_locale!(locale)
            @_source.__locale__ = locale
            @_source.__freeze_locale__
          end

        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.8.0.alpha1 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.7.1 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.7.0 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.6.1 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.6.0 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.6.0.rc1 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.6.0.beta1 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.5.3 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.5.2 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.5.1 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.5.0 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.5.0.rc1 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.5.0.rc0 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.5.0.beta3 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.5.0.beta2 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.5.0.beta1 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.4.1 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.4.0 lib/locomotive/steam/liquid/drops/i18n_base.rb
locomotivecms_steam-1.4.0.rc2 lib/locomotive/steam/liquid/drops/i18n_base.rb