Skip to content

fix(translation): loading translations in menu#35640

Open
jakubhruby wants to merge 21 commits intoapache:masterfrom
jakubhruby:fix/translations
Open

fix(translation): loading translations in menu#35640
jakubhruby wants to merge 21 commits intoapache:masterfrom
jakubhruby:fix/translations

Conversation

@jakubhruby
Copy link
Copy Markdown

@jakubhruby jakubhruby commented Oct 14, 2025

SUMMARY

Translations need to be fully loaded before app is started - it's in superset-frontend/src/preamble.ts where there even is a comment saying Load language pack before anything else, but in fact there is no wait for async translation load.
Some menu items are not translated.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before - translated and non-translated mixed up
Snímek obrazovky z 2025-10-14 14-17-26

After - all strings are loaded
Snímek obrazovky z 2025-10-14 14-37-56

TESTING INSTRUCTIONS

Reoad page and watch all strings are translated (requires fully translated localization, e.g. CS added in #35639)

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@dosubot dosubot Bot added the i18n:general Related to translations label Oct 14, 2025
Copy link
Copy Markdown

@korbit-ai korbit-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Performance Blocking main thread with top-level await ▹ view
Functionality Top-level await without module configuration ▹ view
Files scanned
File Path Reviewed
superset-frontend/src/views/index.tsx
superset-frontend/src/views/menu.tsx
superset-frontend/src/preamble.ts
superset-frontend/src/embedded/index.tsx
superset-frontend/src/features/home/Menu.tsx
superset-frontend/webpack.config.js

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

Comment thread superset-frontend/src/views/index.tsx Outdated
Comment on lines 25 to 27
await i18nLoadJob;

ReactDOM.render(<App />, document.getElementById('app'));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking main thread with top-level await category Performance

Tell me more
What is the issue?

Top-level await blocks the main thread during i18n loading, preventing any UI rendering or user interaction until translation loading completes.

Why this matters

This creates a poor user experience with a blank screen during network delays or slow translation loading, and prevents showing loading indicators or fallback content to users.

Suggested change ∙ Feature Preview

Replace top-level await with asynchronous initialization that shows a loading state while translations load, then renders the app:

import { i18nLoadJob } from '../preamble';

const initializeApp = async () => {
  // Show loading indicator
  ReactDOM.render(<LoadingSpinner />, document.getElementById('app'));
  
  // Load translations
  await i18nLoadJob;
  
  // Render main app
  ReactDOM.render(<App />, document.getElementById('app'));
};

initializeApp();
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Comment thread superset-frontend/src/views/menu.tsx Outdated
@jakubhruby jakubhruby changed the title fix(translation) loading translations before app fix(translation): loading translations before app Oct 16, 2025
@github-actions github-actions Bot added the i18n Namespace | Anything related to localization label Oct 20, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 20, 2025

Codecov Report

❌ Patch coverage is 28.57143% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.36%. Comparing base (d618837) to head (ed87779).

Files with missing lines Patch % Lines
superset-frontend/src/features/home/Menu.tsx 28.57% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #35640   +/-   ##
=======================================
  Coverage   64.36%   64.36%           
=======================================
  Files        2569     2569           
  Lines      134745   134747    +2     
  Branches    31278    31278           
=======================================
+ Hits        86731    86733    +2     
  Misses      46516    46516           
  Partials     1498     1498           
Flag Coverage Δ
javascript 66.61% <28.57%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rusackas
Copy link
Copy Markdown
Member

@dosu didn't someone recently file an issue about loading french translations in their deployment? Maybe this is relevant?

@tahvane1
Copy link
Copy Markdown
Contributor

I applied these changes to my slightly modified 6.0 branch and this long standing issue is finally fixed. Good work!

@tahvane1
Copy link
Copy Markdown
Contributor

I was celebrating too early. With fix these feature flags do not work anymore "ENABLE_DASHBOARD_SCREENSHOT_ENDPOINTS": True,
"ENABLE_DASHBOARD_DOWNLOAD_WEBDRIVER_SCREENSHOT": True,
So it seems authentication or something is broken (and worker can't connect).

@rusackas
Copy link
Copy Markdown
Member

@jakubhruby thanks for working on this — wanted to flag a couple of things before we can move forward:

  1. Regression report from @tahvane1 (comment): with this fix applied, ENABLE_DASHBOARD_SCREENSHOT_ENDPOINTS and ENABLE_DASHBOARD_DOWNLOAD_WEBDRIVER_SCREENSHOT stop working — sounds like the worker is unable to connect/authenticate. My guess is that the headless screenshot path is now stuck waiting on i18nLoadJob because bootstrapData.common.locale isn't populated the same way in that context. Could you take a look and either reproduce or rule it out?

  2. Conflicts with master — the branch needs a rebase before it can be merged.

Once those are addressed I'll take another look. Appreciate the patch — the screenshots in the description make the bug very clear.

Comment thread superset-frontend/src/preamble.ts Outdated
Comment on lines 46 to 55
let i18nLoadResolve: (value?: unknown) => void;

export const I18nLoadJob = new Promise(resolve => {
i18nLoadResolve = resolve;
});

export default function initPreamble(): Promise<void> {
if (initPromise) {
return initPromise;
return initPromise.then(() => i18nLoadResolve());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Architect Review — CRITICAL

I18nLoadJob is never resolved during the initial initPreamble execution: the resolver is only invoked in the if (initPromise) branch, but the first call (triggered at module load) sets initPromise and returns without ever calling i18nLoadResolve. Because the SPA, menu, and embedded entrypoints now await I18nLoadJob at top level, their module evaluation can block indefinitely and prevent the UI from rendering.

Suggestion: Resolve I18nLoadJob from the same async flow that loads translations in initPreamble (success and fallback paths), ensuring the resolver is called on the initial run and not just on subsequent calls. For example, call i18nLoadResolve() in the finally of the language-pack-loading logic before returning the resolved initPromise.

Fix in Cursor | Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is an **Architect / Logical Review** comment left during a code review. These reviews are first-class, important findings — not optional suggestions. Do NOT dismiss this as a 'big architectural change' just because the title says architect review; most of these can be resolved with a small, localized fix once the intent is understood.

**Path:** superset-frontend/src/preamble.ts
**Line:** 46:55
**Comment:**
	*CRITICAL: I18nLoadJob is never resolved during the initial initPreamble execution: the resolver is only invoked in the `if (initPromise)` branch, but the first call (triggered at module load) sets initPromise and returns without ever calling `i18nLoadResolve`. Because the SPA, menu, and embedded entrypoints now `await I18nLoadJob` at top level, their module evaluation can block indefinitely and prevent the UI from rendering.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
If a suggested approach is provided above, use it as the authoritative instruction. If no explicit code suggestion is given, you MUST still draft and apply your own minimal, localized fix — do not punt back with 'no suggestion provided, review manually'. Keep the change as small as possible: add a guard clause, gate on a loading state, reorder an await, wrap in a conditional, etc. Do not refactor surrounding code or expand scope beyond the finding.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix

@netlify
Copy link
Copy Markdown

netlify Bot commented May 4, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 413dd3d
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69fac61323f61600086ab4dc
😎 Deploy Preview https://deploy-preview-35640--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread superset-frontend/src/features/home/Menu.tsx
Comment thread superset-frontend/src/preamble.ts Outdated
Comment on lines +46 to +54
let i18nLoadResolve: (value?: unknown) => void;

export const I18nLoadJob = new Promise(resolve => {
i18nLoadResolve = resolve;
});

export default function initPreamble(): Promise<void> {
if (initPromise) {
return initPromise;
return initPromise.then(() => i18nLoadResolve());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: I18nLoadJob is only resolved in the if (initPromise) branch, but the first initialization path never calls i18nLoadResolve, so the promise can stay pending forever. Resolve (and ideally reject) I18nLoadJob from the primary async initialization completion path, not only on subsequent calls. [logic error]

Severity Level: Critical 🚨
- ❌ Main app entry `views/index.tsx` hangs before render.
- ❌ Menu entry `views/menu.tsx` blocks on unresolved I18nLoadJob.
- ❌ Embedded dashboards `embedded/index.tsx` never start authentication.
- ⚠️ Translations and bootstrap flow cannot complete successfully.
Steps of Reproduction ✅
1. Build and load the main web UI entrypoint `superset-frontend/src/views/index.tsx`,
which imports `{ default as initPreamble, I18nLoadJob }` from `src/preamble` at line 9 and
then performs a top-level `await I18nLoadJob` at line 12.

2. During module loading of `views/index.tsx`, the imported module
`superset-frontend/src/preamble.ts` is evaluated: it defines `I18nLoadJob` as `new
Promise(resolve => { i18nLoadResolve = resolve; })` at lines 48–50 and then immediately
calls `initPreamble().catch(...)` at lines 139–141, which sets `initPromise` at line 57
and starts the async initialization, but does not call `i18nLoadResolve` anywhere in that
first execution path.

3. After `preamble.ts` finishes evaluating, control returns to `views/index.tsx` and
execution reaches the top-level `await I18nLoadJob` at line 12; at this point
`I18nLoadJob` is still pending because its resolver `i18nLoadResolve` (declared at line
46) has not been invoked.

4. The only place `i18nLoadResolve` is ever called is inside `initPreamble()` when
`initPromise` is already non-null, via `return initPromise.then(() => i18nLoadResolve());`
at line 54, but this branch is only executed on subsequent calls to `initPreamble()`;
because `views/index.tsx` awaits `I18nLoadJob` before it ever calls `initPreamble()`
itself (lines 16–22), that second call never happens, `I18nLoadJob` never resolves, and
the main app (and similarly `views/menu.tsx` awaiting `I18nLoadJob` at lines 11–12, and
`embedded/index.tsx` chaining `I18nLoadJob.then(...)` at lines 139–145) hangs indefinitely
waiting for a promise that is never settled.

Fix in Cursor | Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/src/preamble.ts
**Line:** 46:54
**Comment:**
	*Logic Error: `I18nLoadJob` is only resolved in the `if (initPromise)` branch, but the first initialization path never calls `i18nLoadResolve`, so the promise can stay pending forever. Resolve (and ideally reject) `I18nLoadJob` from the primary async initialization completion path, not only on subsequent calls.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread superset-frontend/src/views/index.tsx Outdated
import { logging } from '@apache-superset/core/utils';
import initPreamble from 'src/preamble';

await I18nLoadJob;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Awaiting I18nLoadJob at module top level blocks app boot before initPreamble() is invoked in this file, so when that job is not resolved yet the SPA never mounts. Gate rendering by awaiting initPreamble() directly (or ensure the job is guaranteed to settle before this await). [possible bug]

Severity Level: Critical 🚨
- ❌ SQL Lab /sqllab/ page never renders React application.
- ❌ All spa.html-based views render blank, no UI.
Steps of Reproduction ✅
1. Build and serve the frontend with this PR so that webpack uses the `spa` entry defined
in `superset-frontend/webpack.config.js:7-18`, where `experiments.topLevelAwait` is
enabled (`webpack.config.js:7-10`) and `spa` is configured as
`addPreamble('src/views/index.tsx')` (`webpack.config.js:15-17`), which prepends
`src/preamble.ts` via `PREAMBLE` (`webpack.config.js:259-265`).

2. In a browser, navigate to SQL Lab at `/sqllab/`, which is handled by `SqllabView.root`
in `superset/views/sqllab.py:33-40`; this method calls `self.render_app_template(payload)`
at `sqllab.py:40`, which delegates to `BaseSupersetView.render_app_template` in
`superset/views/base.py:11-35` to render `superset/spa.html` using the `spa` webpack entry
by default (`get_spa_template_context` in `base.py:568-587`).

3. When the browser loads the `spa` bundle, the prepended module
`superset-frontend/src/preamble.ts` executes first: it defines `I18nLoadJob` as a new
Promise with resolver `i18nLoadResolve` at `preamble.ts:46-50` and defines
`initPreamble()` at `preamble.ts:52-133`; at the bottom it immediately calls
`initPreamble()` at `preamble.ts:136-139` to start initialization, but `i18nLoadResolve`
is only wired in the `if (initPromise)` branch of `initPreamble()` (`preamble.ts:52-55`),
which is not taken on this first call, so `I18nLoadJob` remains pending and is never
resolved.

4. After `preamble.ts` finishes its initial call, webpack evaluates the entry module
`superset-frontend/src/views/index.tsx`; module execution reaches the top-level `await
I18nLoadJob;` at `index.tsx:26` before any code in this file can call `initPreamble()`,
and because `I18nLoadJob` never resolves (per step 3), the module evaluation is suspended
indefinitely and the code path that imports `./App` and calls `ReactDOM.render(<App />,
appMountPoint);` at `index.tsx:35-36` is never executed, so the SQL Lab page (and any
other view using the `spa` entry) never mounts the React app and appears as a blank
spinner/empty page.

Fix in Cursor | Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/src/views/index.tsx
**Line:** 26:26
**Comment:**
	*Possible Bug: Awaiting `I18nLoadJob` at module top level blocks app boot before `initPreamble()` is invoked in this file, so when that job is not resolved yet the SPA never mounts. Gate rendering by awaiting `initPreamble()` directly (or ensure the job is guaranteed to settle before this await).

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread superset-frontend/src/views/menu.tsx Outdated
import { I18nLoadJob } from '../preamble';
import querystring from 'query-string';

await I18nLoadJob;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: This top-level await can block the menu bundle forever if I18nLoadJob is still pending, preventing the menu app from initializing. Use initPreamble()-based startup flow (or a guaranteed-settling synchronization promise) before rendering. [possible bug]

Severity Level: Critical 🚨
- ❌ Menu React app never renders on backend-rendered pages.
- ❌ Backend views fail to show navigation menu content.
- ⚠️ I18n translation loading blocks entire menu entrypoint.
Steps of Reproduction ✅
1. The `menu` webpack entrypoint is configured in `superset-frontend/webpack.config.js`
via `menu: addPreamble('src/views/menu.tsx')`, which prepends `src/preamble.ts` before
`src/views/menu.tsx` (verified by `addPreamble` definition in `webpack.config.js:12–14`
from the Read output).

2. When the menu bundle loads in the browser, module `superset-frontend/src/preamble.ts`
runs first: it defines `I18nLoadJob` at lines 48–50 as `new Promise(resolve => {
i18nLoadResolve = resolve; })`, and calls `initPreamble()` once at lines 136–141 to kick
off initialization.

3. `initPreamble()` in `src/preamble.ts:52–55` only calls `i18nLoadResolve()` in the
branch `if (initPromise) { return initPromise.then(() => i18nLoadResolve()); }`; on the
first (module-internal) call `initPromise` is `null`, so that branch is skipped and the
asynchronous initialization body at lines 57–133 never invokes `i18nLoadResolve`, leaving
`I18nLoadJob` pending (confirmed by `Grep` showing `i18nLoadResolve` used only on lines
46–54).

4. After `preamble.ts` finishes evaluating, module `superset-frontend/src/views/menu.tsx`
executes and hits the top-level `await I18nLoadJob;` at line 38, which waits on a promise
that never settles; as a result the code that sets up the Redux store and renders `<Menu
/>` into `#app-menu` at lines 42–45 and 50–71 never runs, so any page that loads the
`menu` bundle (per step 1) will see the menu React app fail to initialize and the header
menu never render.

Fix in Cursor | Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/src/views/menu.tsx
**Line:** 38:38
**Comment:**
	*Possible Bug: This top-level await can block the menu bundle forever if `I18nLoadJob` is still pending, preventing the menu app from initializing. Use `initPreamble()`-based startup flow (or a guaranteed-settling synchronization promise) before rendering.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@jakubhruby jakubhruby marked this pull request as draft May 4, 2026 07:59
@pull-request-size pull-request-size Bot added size/S and removed size/M labels May 5, 2026
@jakubhruby jakubhruby changed the title fix(translation): loading translations before app fix(translation): loading translations May 5, 2026
@jakubhruby jakubhruby changed the title fix(translation): loading translations fix(translation): loading translations in menu May 5, 2026
@jakubhruby jakubhruby marked this pull request as ready for review May 5, 2026 06:56
@dosubot dosubot Bot added the change:frontend Requires changing the frontend label May 5, 2026
@jakubhruby
Copy link
Copy Markdown
Author

Some parts of this PR have been already fixed with implementing async function initPreamble. So I have removed i18nLoad job from this PR code.
Therefore there are just a few missing translation calls remaining in Menu, which are addressed in this PR.

@jakubhruby
Copy link
Copy Markdown
Author

/review

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 5, 2026

Bito In-Progress Reviews Aborted

All in-progress reviews for this pull request have been cancelled. To trigger a new review, type /review in a comment and save.

@jakubhruby
Copy link
Copy Markdown
Author

/abort

@jakubhruby
Copy link
Copy Markdown
Author

/review

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 5, 2026

Code Review Agent Run #139410

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 52542f5..ed87779
    • superset-frontend/src/features/home/Menu.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 5, 2026

Code Review Agent Run #9f17db

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 52542f5..ed87779
    • superset-frontend/src/features/home/Menu.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@jakubhruby
Copy link
Copy Markdown
Author

@rusackas babel-extract chekc is running for 3+ hours, but the others are green

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend i18n:general Related to translations size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants