Sha256: 499cb0c0a3a42d7b3390139633e2dc788f16569c4f908cd9b3c1f8bc65a52c3f

Contents?: true

Size: 602 Bytes

Versions: 246

Compression:

Stored size: 602 Bytes

Contents

module Actions
  module Middleware
    # Keeps the locale value from plan and keeps that in run/finalize
    # so that the error from there are localized correctly
    class KeepLocale < Dynflow::Middleware
      def plan(*args)
        pass(*args).tap { action.input[:locale] = I18n.locale }
      end

      def run(*args)
        with_locale { pass(*args) }
      end

      def finalize
        with_locale { pass }
      end

      private

      def with_locale(&_block)
        I18n.locale = action.input[:locale]
        yield
      ensure
        I18n.locale = nil
      end
    end
  end
end

Version data entries

246 entries across 246 versions & 1 rubygems

Version Path
katello-4.15.0.rc2 app/lib/actions/middleware/keep_locale.rb
katello-4.15.0.rc1 app/lib/actions/middleware/keep_locale.rb
katello-4.14.1 app/lib/actions/middleware/keep_locale.rb
katello-4.14.0 app/lib/actions/middleware/keep_locale.rb
katello-4.14.0.rc3 app/lib/actions/middleware/keep_locale.rb
katello-4.14.0.rc2 app/lib/actions/middleware/keep_locale.rb
katello-4.14.0.rc1.1 app/lib/actions/middleware/keep_locale.rb
katello-4.14.0.rc1 app/lib/actions/middleware/keep_locale.rb
katello-4.13.1 app/lib/actions/middleware/keep_locale.rb
katello-4.13.0 app/lib/actions/middleware/keep_locale.rb
katello-4.12.1 app/lib/actions/middleware/keep_locale.rb
katello-4.13.0.rc1 app/lib/actions/middleware/keep_locale.rb
katello-4.12.0 app/lib/actions/middleware/keep_locale.rb
katello-4.12.0.rc3 app/lib/actions/middleware/keep_locale.rb
katello-4.12.0.rc2 app/lib/actions/middleware/keep_locale.rb
katello-4.12.0.rc1 app/lib/actions/middleware/keep_locale.rb
katello-4.11.1 app/lib/actions/middleware/keep_locale.rb
katello-4.11.0 app/lib/actions/middleware/keep_locale.rb
katello-4.11.0.rc2 app/lib/actions/middleware/keep_locale.rb
katello-4.11.0.rc1 app/lib/actions/middleware/keep_locale.rb