-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
Pundit Authorization localization not working #3487
Comments
Hi @jmarsh24 thanks for opening this issue, the not authorized flash is generated here https://github.com/avo-hq/avo/blob/main/app/controllers/avo/base_application_controller.rb#L236 I'm not sure what is causing it to not render on the correct locale. Let me know if you want to give this a try, we can guide you through the source code |
@Paul-Bob Thanks for looking into this. I'm not sure what fix is being proposed. If caching is turned off, the flash message is correctly translated but when caching is turned on then the flash message seemed to be cached and doesn't change dependent upon the current locale. |
@Paul-Bob I added the translation key to the minimum reproducible repository and the issue persists even without caching. |
What I meant was, since you've marked this as "High urgency (I can't continue development without it)" and we can't prioritize it right now, I'd be happy to walk you through the Avo source code if you want to give it a shot The first step would be to debug avo on the reproduction repository around here and try to understand why the correct locale is not being applied |
@jmarsh24 nevermind, I'll give it a look |
The problem is that when an error pops up, I’m not sure about a solid native fix just yet, but I can suggest a workaround in the meantime
module Avo
class ApplicationController < BaseApplicationController
def render_unauthorized(exception)
# localize is your custom method from app/controllers/concerns/avo_localization.rb
# when following the recipe from here https://docs.avohq.io/3.0/guides/multi-language-urls.html use set_avo_locale isntead of localize
localize do
super
end
end
end
end |
Describe the bug
When caching is turned on and the user get redirected because the policy prevents them from seeing the resource, the flash message doesn't not respect the users local.
Reproduction repository for the bug
jmarsh24/localized_dashboard#20
Steps to use in the reproduction repository
Steps to reproduce the behavior:
Expected behavior & Actual behavior
I would expect the localization to be respected. so german should see Germany and english should see and english flash message
System configuration
Avo version:
3.14
Rails version:
8.0.0
Ruby version:
3.3.5
License type:
Are you using Avo monkey patches, overriding views or view components?
Screenshots or screen recordings
https://share.cleanshot.com/jhFrlDr8
Additional context
Impact
Urgency
The text was updated successfully, but these errors were encountered: