Bug description

I have a question about regional internationalization? In the screenshot, the key for storing FAB babel in cache is ('zh_Cant_TW '), while when [views/base. py] retrieves [bootstrap_data], it passes in zh. This does not match the internationalization file [translations/zh_TW]. This is the conclusion I obtained after debugging.

Screenshots/recordings

Image

Image

Image

Superset version

5.0.0

Python version

3.11

Node version

18 or greater

Browser

Chrome

Additional context

this is my config: ENABLE_CORS = True

开发模式使用 TALISMAN_ENABLED

PREVENT_UNSAFE_DB_CONNECTIONS = False CORS_OPTIONS = { 'supports_credentials': True, 'allow_headers': [''], 'resources': [''], 'origins': ['*'] } FEATURE_FLAGS = { 'ENABLE_TEMPLATE_PROCESSING': True, "EMBEDDED_SUPERSET": True, "HORIZONTAL_FILTER_BAR": True, "MENU_HIDE_USER_INFO": True, "CHART_PLUGINS_EXPERIMENTAL": True, "ENABLE_JAVASCRIPT_CONTROLS": True, "DASHBOARD_CROSS_FILTERS": True, "DASHBOARD_NATIVE_FILTERS": True, "ALERT_REPORTS": False, "SSH_TUNNELING": True, "TAGGING_SYSTEM": True, "OPTIMIZE_SQL": False, "LOCAL_CONFIG_SYSTEM": True, "DYNAMIC_PLUGINS": False, "ENABLE_JAVASCRIPT_CONTROLS": True, "MENU_HIDE_USER_INFO": False, }

LANGUAGES = { "en": {"flag": "us", "name": "English"}, "zh": {"flag": "cn", "name": "简体中文"}, "zh_TW": {"flag": "tw", "name": "繁体中文"}, "th": {"flag": "th", "name": "Thai"}, "vi": {"flag": "vi", "name": "Vietnamese"}, "eo": {"flag": "eo", "name": "Esperanto"}, }

Embedded config options

WTF_CSRF_ENABLED = True

Add endpoints that need to be exempt from CSRF protection

WTF_CSRF_EXEMPT_LIST = [ "superset.views.core.log", "superset.views.core.explore_json", "superset.charts.data.api.data", "superset.dashboards.api.cache_dashboard_screenshot", "superset.wisdytech.token.api.get_guest_token", "superset.security.api.guest_token", "superset.extends.explore.api.get_form_key" "superset.extends.dashboard.api.get_form_key" ]

Checklist

  • [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
  • [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
  • [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Comment From: dosubot[bot]

Hi @HCTzz! I'm Dosu and I’m helping the superset team.

This issue happens because Superset expects the language code sent from the backend to exactly match the translation folder name (like zh_TW), but the backend often sends a simplified code (like zh) or an expanded one (like zh_Hant_TW), which doesn't match your translations/zh_TW folder. As a result, the frontend loads the wrong or fallback language pack, making the zh_TW switch ineffective.

To fix this, you can override the bootstrap locale in your superset/config.py to normalize any variant (such as zh, zh_Hant_TW, or zh_Cant_TW) to zh_TW. Here’s an example:

def override_bootstrap_locale(data):
    # Normalize all Traditional Chinese variants to zh_TW
    if data.get("locale") in ["zh", "zh_Hant_TW", "zh_Cant_TW"]:
        data["locale"] = "zh_TW"
        data["language_pack"] = get_language_pack("zh_TW")
    return data

COMMON_BOOTSTRAP_OVERRIDES_FUNC = override_bootstrap_locale

After making this change, rebuild your frontend translations with:

cd superset-frontend/
npm run build-translation

This ensures the frontend receives and loads the correct language pack for Traditional Chinese. For more details, see this discussion and related code references.

If you still see mixed languages, double-check that your LANGUAGES config includes "zh_TW" and that your translation files are up to date.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

Comment From: HCTzz

Hi @HCTzz! I'm Dosu and I’m helping the superset team.

This issue happens because Superset expects the language code sent from the backend to exactly match the translation folder name (like zh_TW), but the backend often sends a simplified code (like zh) or an expanded one (like zh_Hant_TW), which doesn't match your translations/zh_TW folder. As a result, the frontend loads the wrong or fallback language pack, making the zh_TW switch ineffective.

To fix this, you can override the bootstrap locale in your superset/config.py to normalize any variant (such as zh, zh_Hant_TW, or zh_Cant_TW) to zh_TW. Here’s an example:

def override_bootstrap_locale(data): # Normalize all Traditional Chinese variants to zh_TW if data.get("locale") in ["zh", "zh_Hant_TW", "zh_Cant_TW"]: data["locale"] = "zh_TW" data["language_pack"] = get_language_pack("zh_TW") return data

COMMON_BOOTSTRAP_OVERRIDES_FUNC = override_bootstrap_locale After making this change, rebuild your frontend translations with:

cd superset-frontend/ npm run build-translation This ensures the frontend receives and loads the correct language pack for Traditional Chinese. For more details, see this discussion and related code references.

If you still see mixed languages, double-check that your LANGUAGES config includes "zh_TW" and that your translation files are up to date.

To reply, just mention @dosu.

How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

This method will make the frontend work properly, but there are still issues in Flask Babel. Due to Flask Babel attempting to load internationalization files by attempting to load [zh_Cant_TW, zh], which does not exist, zh will be loaded. Therefore, Simplified Chinese and Traditional Chinese will always be translated into Simplified Chinese in Flask Babel. My solution is: Rename the translations/zh_TW folder to translations/zh_Hant_TW.