Skip to content

Commit

Permalink
SRV-795 feat - reading language from url
Browse files Browse the repository at this point in the history
  • Loading branch information
nyohasstium committed Sep 18, 2024
1 parent c428108 commit 41989a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
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

0 comments on commit 41989a6

Please sign in to comment.