From 6d3b57fe423e18d61ae457a718c0f9901a173ace Mon Sep 17 00:00:00 2001 From: mfo Date: Sat, 25 Nov 2017 19:37:33 +0100 Subject: fix(streaming_template_renderer): I18n.locale broken in layout. I18n gem stores the current locale in Thread.current[:local] (see: https://github.com/svenfuchs/i18n/blob/master/lib/i18n.rb#L23). StreamingTemplateRenderer is implemented with Fiber which have its own stack of locals and can not access Thread.current.locals(keys, see: https://ruby-doc.org/core-2.2.0/Thread.html#class-Thread-label-Fiber-local+vs.+Thread-local). --- actionview/lib/action_view/renderer/streaming_template_renderer.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'actionview/lib/action_view/renderer/streaming_template_renderer.rb') diff --git a/actionview/lib/action_view/renderer/streaming_template_renderer.rb b/actionview/lib/action_view/renderer/streaming_template_renderer.rb index ca49eb1144..276a28ce07 100644 --- a/actionview/lib/action_view/renderer/streaming_template_renderer.rb +++ b/actionview/lib/action_view/renderer/streaming_template_renderer.rb @@ -65,7 +65,9 @@ module ActionView yielder = lambda { |*name| view._layout_for(*name) } instrument(:template, identifier: template.identifier, layout: layout.try(:virtual_path)) do + outer_config = I18n.config fiber = Fiber.new do + I18n.config = outer_config if layout layout.render(view, locals, output, &yielder) else -- cgit v1.2.3