Sha256: 0786b0a572f09e0cfc917588233d6a126a15879db9f3b1ca15f0a5fb87bcb565
Contents?: true
Size: 844 Bytes
Versions: 7
Compression:
Stored size: 844 Bytes
Contents
module Sidekiq::Middleware::I18n # Get the current locale and store it in the message # to be sent to Sidekiq. class Client def call(worker_class, msg, queue) msg['locale'] ||= I18n.locale yield end end # Pull the msg locale out and set the current thread to use it. class Server def call(worker, msg, queue) I18n.locale = msg['locale'] || I18n.default_locale yield ensure I18n.locale = I18n.default_locale end end end Sidekiq.configure_client do |config| config.client_middleware do |chain| chain.add Sidekiq::Middleware::I18n::Client end end Sidekiq.configure_server do |config| config.client_middleware do |chain| chain.add Sidekiq::Middleware::I18n::Client end config.server_middleware do |chain| chain.add Sidekiq::Middleware::I18n::Server end end
Version data entries
7 entries across 7 versions & 1 rubygems