rusackas commented on code in PR #39357:
URL: https://github.com/apache/superset/pull/39357#discussion_r3526347611
##########
superset/views/base.py:
##########
@@ -576,7 +577,24 @@ 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":
+ # Respect a pack already provided via COMMON_BOOTSTRAP_OVERRIDES_FUNC
+ # (the workaround in #35330 does exactly that), otherwise load the
+ # shared one. `get_language_pack` returns the empty English pack on a
+ # miss, which is the right result (English) when no translation file
+ # exists.
+ pack = payload.get("language_pack") or get_language_pack(language)
Review Comment:
I don't think we want this one... an empty `{}` pack isn't a usable
override: `Translator`'s constructor reads `locale_data.superset[''].lang`, so
honoring `{}` would crash the preamble's synchronous configure path for every
non-English user. The truthiness check deliberately degrades a meaningless
empty override to the real pack instead. Also `get_language_pack` caches per
process (`ALL_LANGUAGE_PACKS`), so there's no repeated disk I/O either way.
--
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]