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
Improve the localization concern, moving to around_action #241
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
andyduong1920
force-pushed
the
chore/improve-localization-2
branch
2 times, most recently
from
October 9, 2020 02:28
7f791ca
to
5233f9d
Compare
byhbt
reviewed
Oct 12, 2020
byhbt
reviewed
Oct 14, 2020
andyduong1920
force-pushed
the
chore/improve-localization-2
branch
from
October 14, 2020 03:23
6051ae0
to
f2e57fb
Compare
@byhbt I adjust the PR base on your comment by adding the comment and change the split from |
byhbt
approved these changes
Oct 14, 2020
andyduong1920
changed the title
Improve the localization concern, moving to around_action #133
Improve the localization concern, moving to around_action
Oct 14, 2020
.template/variants/api/app/controllers/concerns/localization.rb
Outdated
Show resolved
Hide resolved
rafayet-monon
approved these changes
Oct 14, 2020
noor-ahmed
approved these changes
Oct 14, 2020
.template/variants/api/app/controllers/concerns/localization.rb
Outdated
Show resolved
Hide resolved
andyduong1920
force-pushed
the
chore/improve-localization-2
branch
from
October 14, 2020 10:49
f2e57fb
to
0e06c49
Compare
.template/variants/api/app/controllers/concerns/localization.rb
Outdated
Show resolved
Hide resolved
junan
approved these changes
Oct 14, 2020
ankitkalia1195
approved these changes
Oct 15, 2020
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #127
What happened
Insight
Switch the locale by using before_action isn't safe, the locale doesn't set return correctly on some request randomly (I faced with that issue on a project).
Here is a similar issue: ruby-i18n/i18n#381
And the official Rails guide also prefer to using around_action to switch the locale https://guides.rubyonrails.org/i18n.html#managing-the-locale-across-requests (rails/rails#34356)
I also add the configuration for the I18n as since from Rails I18n 1.1.0, the config
config.i18n.fallbacks = true
(was generated by Rails) isn't correct anymore https://github.com/ruby-i18n/i18n/releases/tag/v1.1.0Proof Of Work