Skip to content
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

SRV-795 feat - reading language from url #4

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions superset-frontend/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ export const URL_PARAMS = {
name: 'focused_chart',
type: 'number',
},
language: {
name: 'lang',
type: 'string'
},
currency: {
name: 'currency',
type: 'string'
}
} as const;

export const RESERVED_CHART_URL_PARAMS: string[] = [
Expand Down
2 changes: 1 addition & 1 deletion superset/security/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2652,7 +2652,7 @@ def has_guest_access(self, dashboard: "Dashboard") -> bool:
return False

dashboards = [
r for r in user.resources if r["type"] == GuestTokenResourceType.DASHBOARD
r for r in user.resources if r["type"] == GuestTokenResourceType.DASHBOARD.value
]

# TODO (embedded): remove this check once uuids are rolled out
Expand Down
6 changes: 5 additions & 1 deletion superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
redirect,
Response,
session,
request
)
from flask_appbuilder import BaseView, expose, Model, ModelView
from flask_appbuilder.actions import action
Expand Down Expand Up @@ -347,8 +348,11 @@ def cached_common_bootstrap_data( # pylint: disable=unused-argument


def common_bootstrap_payload() -> dict[str, Any]:
locale = get_locale()
if request.args.get('lang'):
locale = Locale.parse(request.args.get('lang'))
return {
**cached_common_bootstrap_data(utils.get_user_id(), get_locale()),
**cached_common_bootstrap_data(utils.get_user_id(), locale),
"flash_messages": get_flashed_messages(with_categories=True),
}

Expand Down