alex-poor commented on code in PR #39357:
URL: https://github.com/apache/superset/pull/39357#discussion_r3440990713
##########
superset/views/base.py:
##########
@@ -550,7 +551,22 @@ def common_bootstrap_payload() -> dict[str, Any]:
locale = get_locale()
# Convert locale to string for proper cache key hashing
locale_str = str(locale) if locale else None
- return cached_common_bootstrap_data(utils.get_user_id(), locale_str)
+ payload = dict(cached_common_bootstrap_data(utils.get_user_id(),
locale_str))
+ # Inject the Jed language pack outside the per-user memoize so the cached
+ # payload stays small and the pack is shared across users for the same
+ # locale. The frontend uses it to configure the translator synchronously,
+ # before any code-split chunk evaluates a module-level `const X = t('...')`
+ # (upstream issue #35330).
+ language = payload.get("locale")
+ if language and language != "en":
+ # `get_language_pack` falls back to an empty English pack on miss;
+ # treat empty as "no pack" so the frontend can fall through to the
+ # async fetch instead of configuring with an empty translator.
+ pack = get_language_pack(language) or None
+ else:
+ pack = None
+ payload["language_pack"] = pack
Review Comment:
Applied, thanks. Kept your point about `COMMON_BOOTSTRAP_OVERRIDES_FUNC:
pack = payload.get("language_pack") or get_language_pack(language)`, with the
dead `or None` removed and the comment corrected to reflect that
`get_language_pack` returns the empty English pack (not a falsy value) on a
miss.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]