tt-a1i opened a new pull request, #36893:
URL: https://github.com/apache/superset/pull/36893

   ## Summary
   
   Fixes the partial translation issue where UI elements display in English 
even when a non-English default language is configured.
   
   **Root cause:** The language pack loads asynchronously in an IIFE, but React 
renders immediately without waiting. This creates a race condition where `t()` 
is called before translations are available.
   
   ## Changes
   
   ### Backend (`superset/views/base.py`)
   - Use `BABEL_DEFAULT_LOCALE` config as fallback instead of hardcoded `"en"`
   - Ensures unauthenticated users get the correct locale in bootstrap data
   
   ### Frontend (`superset-frontend/src/preamble.ts`)
   - Refactor from IIFE to exported `initPreamble()` function returning 
`Promise<void>`
   - Add singleton pattern to prevent duplicate initialization
   
   ### Frontend (`superset-frontend/src/views/index.tsx`)
   - Await `initPreamble()` before rendering React app
   - Use `try/finally` to ensure app renders even if language pack fails
   
   ## Before/After
   
   **Before:**
   ```
   1. preamble IIFE starts, requests language pack
   2. ReactDOM.render() executes immediately
   3. t('Sign in') → "Sign in" (English, pack not loaded yet)
   4. Language pack loads (too late)
   ```
   
   **After:**
   ```
   1. await initPreamble() - waits for language pack
   2. t() is configured with correct translations
   3. ReactDOM.render() executes
   4. t('Sign in') → "登录" (correct translation)
   ```
   
   ## Test Plan
   
   1. Set `BABEL_DEFAULT_LOCALE = "zh"` (or any non-English locale)
   2. Clear browser cache and cookies
   3. Visit `/login/` in incognito mode
   4. Verify login page displays in the configured language
   5. Verify language switching still works after login
   
   Fixes #35569


-- 
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]

Reply via email to