Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
StreamingTemplateRenderer fails to forward I18n.locale in layouts #30361
I recently used the option
We noticed that our layout failed to keep the current locale [I18n.locale]. After some explorations, here is what happens :
This commit includes a simple fix: keeping a reference of the I18n.config above the Fiber scope and re-applying this reference to I18n.config.
Here is a link to a gist (https://gist.github.com/mfo/e8e5d51fe52f6cacd33ea778b1ef6c6d) with other options :
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @eileencodes (or someone else) soon.
If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.
This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.
Please see the contribution instructions for more information.
Maybe you are in holiday and in this case I wish you the best :-)
In case I missed something and it's a pain to deal with this issue, here is a simple rails app which reproduces this bug with a dedicated test : https://github.com/mfo/rails_30361
…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).
Sorry I'm closing/reopening this PR to relaunch the CI which failed on some apt-get :