codeant-ai-for-open-source[bot] commented on code in PR #42154:
URL: https://github.com/apache/superset/pull/42154#discussion_r3607255495


##########
superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx:
##########
@@ -121,14 +121,53 @@ use([
   LabelLayout,
 ]);
 
+// Explicit per-locale imports rather than a template-literal dynamic
+// import: a computed import makes bundlers build a "context module" over
+// echarts/i18n, and resolving that directory through the echarts package's
+// `exports` map fails intermittently in webpack incremental builds
+// ("Package path ./i18n is exported ... but no valid target file was
+// found"). A static map is also the only thing that lets bundlers
+// code-split exactly the locales listed here. Keys are Superset locales
+// uppercased; echarts locales absent from this map fall back to English.
+const LOCALE_LOADERS: Record<string, () => Promise<{ default: object }>> = {
+  AR: () => import('echarts/i18n/langAR.js'),
+  CS: () => import('echarts/i18n/langCS.js'),
+  DE: () => import('echarts/i18n/langDE.js'),
+  EL: () => import('echarts/i18n/langEL.js'),
+  EN: () => import('echarts/i18n/langEN.js'),
+  ES: () => import('echarts/i18n/langES.js'),
+  FA: () => import('echarts/i18n/langFA.js'),
+  FI: () => import('echarts/i18n/langFI.js'),
+  FR: () => import('echarts/i18n/langFR.js'),
+  HU: () => import('echarts/i18n/langHU.js'),
+  IT: () => import('echarts/i18n/langIT.js'),
+  JA: () => import('echarts/i18n/langJA.js'),
+  KO: () => import('echarts/i18n/langKO.js'),
+  LV: () => import('echarts/i18n/langLV.js'),
+  NL: () => import('echarts/i18n/langNL.js'),
+  PL: () => import('echarts/i18n/langPL.js'),
+  RO: () => import('echarts/i18n/langRO.js'),
+  RU: () => import('echarts/i18n/langRU.js'),
+  SI: () => import('echarts/i18n/langSI.js'),

Review Comment:
   **Suggestion:** The locale map key for Slovenian is incorrect: Superset 
locale codes are uppercased before lookup, so `sl` becomes `SL`, but this map 
uses `SI`. This guarantees the loader is never selected for Slovenian users and 
forces an unintended fallback path. Change the key to match Superset’s locale 
code normalization. [incorrect variable usage]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ ECharts charts ignore Slovenian locale, stay in English.
   - ⚠️ Slovenian explore and dashboard charts remain untranslated.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Enable Slovenian as a UI language using the LANGUAGES mapping in 
`superset/config.py`
   at lines 520-36, which defines the locale key `"sl": {"flag": "si", "name": 
"Slovenian"}`.
   
   2. Start Superset with this configuration and set the application language 
to Slovenian so
   that the Redux `common.locale` value becomes `"sl"` (as defined by the 
LANGUAGES keys in
   `superset/config.py:520-36`).
   
   3. Render any ECharts-based visualization (for example via the Explore view) 
which uses
   the `Echart` React component in
   
`superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx:186-255`.
   
   4. In `Echart.tsx:219-221`, the locale is computed as `const locale = ...
   .toUpperCase();`, so `"sl"` becomes `"SL"`, but `loadLocale()` at 
`Echart.tsx:160-171`
   looks up `LOCALE_LOADERS[locale]` and `LOCALE_LOADERS` at 
`Echart.tsx:132-158` defines a
   key `SI` (line 151) instead of `SL`, causing `loader` to be undefined and 
`loadLocale` to
   return `undefined`, so `registerLocale` at `Echart.tsx:235-239` is never 
called and
   ECharts falls back to English for Slovenian users.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=3aa4377b5523446ab3d0641dcd2a9e9c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=3aa4377b5523446ab3d0641dcd2a9e9c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx
   **Line:** 151:151
   **Comment:**
        *Incorrect Variable Usage: The locale map key for Slovenian is 
incorrect: Superset locale codes are uppercased before lookup, so `sl` becomes 
`SL`, but this map uses `SI`. This guarantees the loader is never selected for 
Slovenian users and forces an unintended fallback path. Change the key to match 
Superset’s locale code normalization.
   
   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
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42154&comment_hash=19f6bd12025999c50a0f7f63c1e03447070f9f7a620db737928befb63a860de8&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42154&comment_hash=19f6bd12025999c50a0f7f63c1e03447070f9f7a620db737928befb63a860de8&reaction=dislike'>👎</a>



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