We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Vanilla behaviour:
When adding gem 'route_translator', '4.0.0' to Gemfile, the I18n.locale is back to default instead (step 3).
gem 'route_translator', '4.0.0'
I'll add a basic rails project that reproduces the error.
The text was updated successfully, but these errors were encountered:
Error reproduced in https://github.com/GSI/route_translator-88
Sorry, something went wrong.
Hmm... this should not be an error... route_translator runs your controller code inside a block and then restores I18n.locale
route_translator
you could skip route_translator in this way
class StaticController < ApplicationController skip_around_action :set_locale_from_url, only: [:unlocalized] def unlocalized I18n.locale = params[:locale] end end
and your test will pass
$ rake test # Running: . Finished in 0.072595s, 13.7751 runs/s, 27.5501 assertions/s.
But... I advise you to use around_action for your purposes
around_action
class StaticController < ApplicationController skip_around_action :set_locale_from_url, only: [:unlocalized] around_action :set_locale_from_param, only: [:unlocalized] private def set_locale_from_param I18n.with_locale params[:locale] do yield end end end
Your test will fail, but you will not experience stuff like #44.
Related comments: #44 (comment) #44 (comment)
Closing here
No branches or pull requests
Vanilla behaviour:
When adding
gem 'route_translator', '4.0.0'
to Gemfile, the I18n.locale is back to default instead (step 3).I'll add a basic rails project that reproduces the error.
The text was updated successfully, but these errors were encountered: