eschutho opened a new pull request, #40729:
URL: https://github.com/apache/superset/pull/40729
### SUMMARY
Fixes a race condition where `t()` calls inside chart plugin control panel
configs and menu components were evaluated and cached before the language pack
finished loading, causing translated strings to appear in English when a
non-English locale is configured.
**Root cause:** `preamble.ts` is prepended to all webpack entry points and
starts `initPreamble()` eagerly, but the language pack fetch is async. In two
entry points, synchronous module-level code ran before that promise resolved:
- **`embedded/index.tsx`**: `setupPlugins()` was called at module top level.
Webpack evaluates this synchronously at bundle parse time, pulling in the
entire chart plugin module tree. All module-level `t()` calls in control panel
configs execute and cache English strings before the language pack arrives.
- **`menu.tsx`**: `createRoot().render()` was called synchronously, so React
could begin rendering Menu components (and evaluating their `t()` calls) before
the language pack resolved.
The `spa` entry point (`views/index.tsx`) already handled this correctly: it
`await`s `initPreamble()` before doing `import('./App')` with `webpackMode:
"eager"`, which defers the entire App module tree evaluation until after the
language pack loads.
**Changes:**
- `embedded/index.tsx`: Removes top-level `setupPlugins()` /
`setupCodeOverrides()` and replaces them with a `pluginsReady` promise that
chains off `initPreamble()`. `start()` (which triggers rendering) chains off
`pluginsReady`, guaranteeing plugins are initialized with translations before
the dashboard renders. If preamble fails for non-language-pack reasons, plugins
still load and the page renders in English rather than showing nothing.
- `menu.tsx`: Wraps `createRoot().render()` in
`initPreamble().catch().then()` so the menu only renders after the language
pack is configured.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Tested with German locale (`de`) and a 2-second artificial delay injected on
the language pack endpoint via `page.route()`.
**menu.tsx** — page heading and section labels render in German despite the
delay:

Verified strings: **Startseite** (Home), **Zuletzt verwendet** (Recents),
**Diagramme** (Charts), **Gespeicherte Abfragen** (Saved queries)
**embedded/index.tsx** — auth error message renders in German, confirming
`start()` waited for `pluginsReady` before calling `t()`:
Verified string: **Bei der eingebetteten Authentifizierung ist ein Fehler
aufgetreten. Weitere Details im Entwicklerkonsolenfenster.**
### TESTING INSTRUCTIONS
1. Configure Superset with a non-English locale (e.g. `BABEL_DEFAULT_LOCALE
= 'de'`).
2. In a browser devtools network throttle or via a proxy, add latency to the
`/superset/language_pack/<lang>/` response.
3. Load a backend-rendered Flask view (e.g. `/superset/welcome/`) — verify
menu labels appear in the configured language, not English.
4. Load an embedded dashboard (`/embedded/<uuid>/`) — verify any UI strings
(including error messages) appear in the configured language.
5. Verify that if the language pack endpoint is slow or fails entirely, the
page still renders correctly in English (no blank screen).
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]