-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StreamingTemplateRenderer fails to forward I18n.locale in layouts #30361
Conversation
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mfo sorry for the delay on merging this. I think this looks good. Can you squash your commits into 1 single commit? Thanks!
…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).
I assumed you ran out of coffee : no worries for the delay ;-) It's squashed & up to date with rails/master. Thanks for your work. 👍 |
Sorry I'm closing/reopening this PR to relaunch the CI which failed on some apt-get :
|
again I'm trying to pass the tests which sometimes fails and sometimes succeed ; let me know if I can help :-) |
The failures aren't related to your branch so I merged. Sorry for the delay with this. Appreciate your time and patience! 😄 |
Thanks for your work Eileen and no worry for the delay. |
Hello,
I recently used the option
render stream: true
to render some actions ( Ruby 2.4.1p111 / Rails 5.1.3 )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 :