-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Redirect happens whenever user changes language #12768
Comments
I have same problem, how to fix it? |
I encountered the same problem and solved it with a monkey patch. It is effective but not elegant enough. I also submit a PR to Flask-AppBuilder as a improvement. It is because not all pages call What I did
def monkey_patch(self) -> None:
@expose("/<string:locale>")
def patch_flask_locale_index(self, locale):
from flask import abort, redirect, session, request
from flask_babel import refresh
from flask_appbuilder.urltools import Stack
if locale not in self.appbuilder.bm.languages:
abort(404, description="Locale not supported.")
if request.referrer is not None:
page_history = Stack(session.get("page_history", []))
page_history.push(request.referrer)
session["page_history"] = page_history.to_json()
session["locale"] = locale
refresh()
self.update_redirect()
return redirect(self.get_redirect())
from flask_appbuilder.babel.views import LocaleView
LocaleView.index = patch_flask_locale_index
def configure_fab(self) -> None:
if self.config["SILENCE_FAB"]:
logging.getLogger("flask_appbuilder").setLevel(logging.ERROR)
custom_sm = self.config["CUSTOM_SECURITY_MANAGER"] or SupersetSecurityManager
if not issubclass(custom_sm, SupersetSecurityManager):
raise Exception(
"""Your CUSTOM_SECURITY_MANAGER must now extend SupersetSecurityManager,
not FAB's security manager.
See [4565] in UPDATING.md"""
)
self.monkey_patch()
appbuilder.indexview = SupersetIndexView
appbuilder.base_template = "superset/base.html"
appbuilder.security_manager_class = custom_sm
appbuilder.init_app(self.flask_app, db.session) That's it. |
Can you please confirm you are still facing this bug / close it not --thanks! |
This Bug continues to exist in V 1.4.2 |
I just tried this on master, and it still exists. I'll assign this to a couple people that might know a way to resolve this, but I think in general, I'll leave this open and in the unfortunate ol' "PRs welcome" status. |
Any update? Bug still exists in version 2.1.0. |
Probably still an issue... I don't think I've seen anyone working on it, strangely. |
This issue is at risk of being closed as stale, though the behavior still exists as of 4.0.1. All the links just point to their relative language URL (e.g. http://localhost:8088/lang/zh_TW) which by default navigates to the Welcome page. @tianhe1986 would you want to open a PR making a solution along the lines you suggest more official, @dpgaspar do you know of any better/easier way to keep the user on their current page/URL when changing language? |
This was just reported again on the linked issue. Not so stale anymore :) |
I have the same problem, but when I change the language, it doesn't redirect me to the user section; instead, it takes me to the homepage. |
I suggest this option, it works well for
|
When the user presses on change language a redirect to
/users/list
happens. I think, in terms of UX, it should remain on the same page as before changing the language.Expected results
Remain on the same page, but translated into a different language.
Actual results
Redirects to
users/list
.Screenshots
How to reproduce the bug
Environment
(please complete the following information):
0.999.0dev
3.7.4
v14.11.0
Checklist
Make sure to follow these steps before submitting your issue - thank you!
The text was updated successfully, but these errors were encountered: