Skip to content

Conversation

@innovark37
Copy link
Contributor

@innovark37 innovark37 commented Oct 6, 2025

… when a non‑English language is selected

SUMMARY

Call setupFormatters synchronously so that the custom D3_FORMAT is applied when a non‑English language is selected. See related issue #35524 for more details.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

BEFORE
1_1

AFTER
1_2

TESTING INSTRUCTIONS

  1. In config.py set the LANGUAGES and D3_FORMAT variables, for example:
LANGUAGES = {
    "en": {"flag": "us", "name": "English"},
    "es": {"flag": "es", "name": "Spanish"},
    "it": {"flag": "it", "name": "Italian"},
    "fr": {"flag": "fr", "name": "French"},
    "zh": {"flag": "cn", "name": "Chinese"},
    "zh_TW": {"flag": "tw", "name": "Traditional Chinese"},
    "ja": {"flag": "jp", "name": "Japanese"},
    "de": {"flag": "de", "name": "German"},
    "pl": {"flag": "pl", "name": "Polish"},
    "pt": {"flag": "pt", "name": "Portuguese"},
    "pt_BR": {"flag": "br", "name": "Brazilian Portuguese"},
    "ru": {"flag": "ru", "name": "Russian"},
    "ko": {"flag": "kr", "name": "Korean"},
    "sk": {"flag": "sk", "name": "Slovak"},
    "sl": {"flag": "si", "name": "Slovenian"},
    "nl": {"flag": "nl", "name": "Dutch"},
    "uk": {"flag": "uk", "name": "Ukranian"},
}

class D3Format(TypedDict, total=False):
    decimal: str
    thousands: str
    grouping: list[int]
    currency: list[str]

D3_FORMAT: D3Format = {
  "decimal": ",",
  "thousands": "\u00a0",
  "grouping": [3],
  "currency": ["", "\u00a0\u20bd"]
}
  1. Open Superset, switch the UI language to any language other than English (e.g., Spanish, French, etc.).
  2. Observe the number formatting on charts and tables. The formatting should match the custom D3_FORMAT.

ADDITIONAL INFORMATION

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Oct 6, 2025

Code Review Agent Run #df2b36

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 3a51c43..3a51c43
    • superset-frontend/src/preamble.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • 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 Default Agent You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

Copy link

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

I've completed my review and didn't find any issues.

Files scanned
File Path Reviewed
superset-frontend/src/preamble.ts

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

@sadpandajoe sadpandajoe added the review:checkpoint Last PR reviewed during the daily review standup label Oct 6, 2025
@dosubot dosubot bot added the i18n Namespace | Anything related to localization label Oct 7, 2025
Copy link
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

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

Claude's analysis:

PR #35529 Review - D3 Format Fix

What Changed

The PR moves the setupFormatters() call outside the async IIFE (immediately invoked function
expression) to execute it synchronously right after getBootstrapData(), instead of inside the async
block where it runs after the language pack is fetched.

Location: superset-frontend/src/preamble.ts:58-93

Why It Matters

This is a regression fix for a bug introduced in PR #34119. Here's the sequence of events:

  1. Before PR #34119: Everything ran synchronously, D3 formatters worked correctly for all languages
  2. PR #34119 introduced: Language pack async loading - moved setupFormatters() inside the async
    block
  3. Regression: When non-English languages are selected, the language pack loading triggers a second
    call to configure() (line 70), which resets D3 formatters to language-specific defaults, overwriting
    the custom D3_FORMAT from config.py
  4. This PR fixes: By calling setupFormatters() synchronously first, then again after language pack
    loads, the custom formats are properly applied

Behavioral Impact

Without this fix:

  • English users: ✅ Custom D3_FORMAT works (no language pack fetch, no configure() reset)
  • Non-English users: ❌ Custom D3_FORMAT ignored, reverts to D3 defaults

With this fix:

  • All users: ✅ Custom D3_FORMAT respected for number/currency formatting

Is It Safe to Merge?

YES, this is super-safe. Here's why:

  1. No breaking changes: Only moves existing code, doesn't modify logic
  2. Small scope: 10-line change (5 additions, 5 deletions) in a single file
  3. Idempotent operation: setupFormatters() can safely be called multiple times - the second call
    (inside async block) simply reinforces the settings
  4. Fixes documented regression: Addresses issue #35524 with clear before/after screenshots
  5. No dependencies: The function only needs bootstrapData which is already available synchronously
  6. Tested pattern: This restores the original synchronous behavior that worked in v5.0.0

Technical Details

The setupFormatters() function from superset-frontend/src/setup/setupFormatters.ts configures D3's
number/time formatting globally. It needs to run:

  1. Early - before any charts/visualizations render
  2. After configure() calls - to ensure custom formats aren't overwritten

The fix satisfies both requirements by calling it synchronously, then again inside the async block
(defensive redundancy).

Recommendation

✅ SAFE TO MERGE - This is a clean regression fix with no risk and clear user benefit for
internationalization.

@mistercrunch mistercrunch merged commit c38ba1d into apache:master Oct 11, 2025
83 of 84 checks passed
@sadpandajoe sadpandajoe added v6.0 Label added by the release manager to track PRs to be included in the 6.0 branch and removed review:checkpoint Last PR reviewed during the daily review standup labels Oct 14, 2025
sadpandajoe pushed a commit that referenced this pull request Oct 14, 2025
amaannawab923 pushed a commit to amaannawab923/superset that referenced this pull request Oct 16, 2025
@innovark37 innovark37 deleted the innovark/fix/custom-d3-format branch December 9, 2025 08:30
@github-actions github-actions bot added 🍒 6.0.0 Cherry-picked to 6.0.0 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels labels Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels i18n Namespace | Anything related to localization size/S v6.0 Label added by the release manager to track PRs to be included in the 6.0 branch 🍒 6.0.0 Cherry-picked to 6.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[6.0.0‑RC2] Custom D3_FORMAT is applied only when the UI language is English

3 participants