Skip to content

Commit

Permalink
fix: Locale sent to frontend (#27926)
Browse files Browse the repository at this point in the history
(cherry picked from commit 996cced)
  • Loading branch information
michael-s-molina committed Apr 16, 2024
1 parent af9dc6f commit e6ff82f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import simplejson as json
import yaml
from babel import Locale
from flask import (
abort,
flash,
Expand Down Expand Up @@ -365,9 +366,11 @@ def menu_data(user: User) -> dict[str, Any]:
"languages": languages,
"show_language_picker": len(languages) > 1,
"user_is_anonymous": user.is_anonymous,
"user_info_url": None
if is_feature_enabled("MENU_HIDE_USER_INFO")
else appbuilder.get_url_for_userinfo,
"user_info_url": (
None
if is_feature_enabled("MENU_HIDE_USER_INFO")
else appbuilder.get_url_for_userinfo
),
"user_logout_url": appbuilder.get_url_for_logout,
"user_login_url": appbuilder.get_url_for_login,
"locale": session.get("locale", "en"),
Expand All @@ -377,7 +380,7 @@ def menu_data(user: User) -> dict[str, Any]:

@cache_manager.cache.memoize(timeout=60)
def cached_common_bootstrap_data( # pylint: disable=unused-argument
user_id: int | None, locale: str
user_id: int | None, locale: Locale | None
) -> dict[str, Any]:
"""Common data always sent to the client
Expand Down Expand Up @@ -405,10 +408,12 @@ def cached_common_bootstrap_data( # pylint: disable=unused-argument
available_specs = get_available_engine_specs()
frontend_config["HAS_GSHEETS_INSTALLED"] = bool(available_specs[GSheetsEngineSpec])

language = locale.language if locale else "en"

bootstrap_data = {
"conf": frontend_config,
"locale": locale,
"language_pack": get_language_pack(locale),
"locale": language,
"language_pack": get_language_pack(language),
"d3_format": conf.get("D3_FORMAT"),
"currencies": conf.get("CURRENCIES"),
"feature_flags": get_feature_flags(),
Expand Down

0 comments on commit e6ff82f

Please sign in to comment.