You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2026/06/03 01:24:35 UTC

(superset) branch ivanti-translations created (now 1a42a6686cd)

This is an automated email from the ASF dual-hosted git repository.

eschutho pushed a change to branch ivanti-translations
in repository https://gitbox.apache.org/repos/asf/superset.git


      at 1a42a6686cd fix(i18n): defer plugin init and menu render until language pack is ready

This branch includes the following new commits:

     new 1a42a6686cd fix(i18n): defer plugin init and menu render until language pack is ready

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 01/01: fix(i18n): defer plugin init and menu render until language pack is ready

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

eschutho pushed a commit to branch ivanti-translations
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 1a42a6686cd2d8584e5a3016e9456d1d72920bfe
Author: Elizabeth Thompson <es...@gmail.com>
AuthorDate: Wed Jun 3 01:24:24 2026 +0000

    fix(i18n): defer plugin init and menu render until language pack is ready
    
    In embedded/index.tsx, setupPlugins() was called at module top level,
    causing it to run synchronously before initPreamble()'s async language
    pack fetch could resolve. All chart plugin control panel t() calls were
    therefore cached in English. This fix chains plugin setup off the
    initPreamble() promise so the language pack is always configured first.
    
    In menu.tsx (used for backend-rendered Flask views), createRoot().render()
    was called synchronously, allowing React to render Menu components before
    the language pack resolved. This fix defers render until initPreamble()
    settles.
    
    The spa entry point (views/index.tsx) already handled this correctly via
    a dynamic import after awaiting initPreamble().
    
    Co-Authored-By: Claude Sonnet 4.6 <no...@anthropic.com>
---
 superset-frontend/src/embedded/index.tsx | 70 +++++++++++++++++++-------------
 superset-frontend/src/views/menu.tsx     |  7 +++-
 2 files changed, 48 insertions(+), 29 deletions(-)

diff --git a/superset-frontend/src/embedded/index.tsx b/superset-frontend/src/embedded/index.tsx
index 1a4a9eebcc9..a6ea98811ef 100644
--- a/superset-frontend/src/embedded/index.tsx
+++ b/superset-frontend/src/embedded/index.tsx
@@ -32,6 +32,7 @@ import {
 } from '@apache-superset/core/theme';
 import Switchboard from '@superset-ui/switchboard';
 import getBootstrapData, { applicationRoot } from 'src/utils/getBootstrapData';
+import initPreamble from 'src/preamble';
 import setupClient from 'src/setup/setupClient';
 import setupPlugins from 'src/setup/setupPlugins';
 import { useUiConfig } from 'src/components/UiConfigContext';
@@ -49,8 +50,19 @@ import {
 import { embeddedApi } from './api';
 import { getDataMaskChangeTrigger } from './utils';
 
-setupPlugins();
-setupCodeOverrides({ embedded: true });
+// Defer plugin setup until after the language pack loads to prevent t() calls in
+// plugin control panel configs from being cached in English before translations are ready.
+const pluginsReady = initPreamble()
+  .catch(err => {
+    logging.warn(
+      'Preamble initialization failed, loading plugins without translations.',
+      err,
+    );
+  })
+  .then(() => {
+    setupPlugins();
+    setupCodeOverrides({ embedded: true });
+  });
 
 const debugMode = process.env.WEBPACK_MODE === 'development';
 const bootstrapData = getBootstrapData();
@@ -184,32 +196,34 @@ function start() {
     method: 'GET',
     endpoint: '/api/v1/me/roles/',
   });
-  return getMeWithRole().then(
-    ({ result }) => {
-      // fill in some missing bootstrap data
-      // (because at pageload, we don't have any auth yet)
-      // this allows the frontend's permissions checks to work.
-      bootstrapData.user = result;
-      store.dispatch({
-        type: USER_LOADED,
-        user: result,
-      });
-      if (!root) {
-        root = createRoot(appMountPoint);
-      }
-      root.render(<EmbeddedApp />);
-    },
-    err => {
-      // something is most likely wrong with the guest token; reset the guard
-      // so a rehandshake with a valid token can retry.
-      logging.error(err);
-      showFailureMessage(
-        t(
-          'Something went wrong with embedded authentication. Check the dev console for details.',
-        ),
-      );
-      started = false;
-    },
+  return pluginsReady.then(() =>
+    getMeWithRole().then(
+      ({ result }) => {
+        // fill in some missing bootstrap data
+        // (because at pageload, we don't have any auth yet)
+        // this allows the frontend's permissions checks to work.
+        bootstrapData.user = result;
+        store.dispatch({
+          type: USER_LOADED,
+          user: result,
+        });
+        if (!root) {
+          root = createRoot(appMountPoint);
+        }
+        root.render(<EmbeddedApp />);
+      },
+      err => {
+        // something is most likely wrong with the guest token; reset the guard
+        // so a rehandshake with a valid token can retry.
+        logging.error(err);
+        showFailureMessage(
+          t(
+            'Something went wrong with embedded authentication. Check the dev console for details.',
+          ),
+        );
+        started = false;
+      },
+    ),
   );
 }
 
diff --git a/superset-frontend/src/views/menu.tsx b/superset-frontend/src/views/menu.tsx
index dda01a8e27e..fb9cd5dd3d2 100644
--- a/superset-frontend/src/views/menu.tsx
+++ b/superset-frontend/src/views/menu.tsx
@@ -31,6 +31,7 @@ import { ThemeProvider } from '@apache-superset/core/theme';
 import { theme } from '@apache-superset/core/theme';
 import Menu from 'src/features/home/Menu';
 import getBootstrapData from 'src/utils/getBootstrapData';
+import initPreamble from 'src/preamble';
 import { setupStore } from './store';
 import querystring from 'query-string';
 
@@ -67,5 +68,9 @@ const app = (
 
 const menuMountPoint = document.getElementById('app-menu');
 if (menuMountPoint) {
-  createRoot(menuMountPoint).render(app);
+  initPreamble()
+    .catch(() => {}) // preamble logs failures internally; always render the menu
+    .then(() => {
+      createRoot(menuMountPoint).render(app);
+    });
 }