Skip to content

fix(i18n): load the dayjs locale for every language with a catalog - #45982

Merged
rusackas merged 2 commits into
apache:masterfrom
antalotec:fix/i18n-dayjs-locales
Nov 21, 2026
Merged

rusackas merged 2 commits into
apache:masterfrom
antalotec:fix/i18n-dayjs-locales

Conversation

@antalotec

Copy link
Copy Markdown
Contributor

SUMMARY

dayjs.locale(name) is a silent no-op when name was never imported: dayjs keeps the
locale already in effect and returns that name instead of the one asked for. Nothing
throws and nothing is logged.

preamble.ts calls dayjs.locale(toDayjsLocale(lang)) for whatever language the user is
on, for all 30 languages that have a catalog under superset/translations/. But
useLocale.ts imports only 16 of them — the same 16 that LOCALE_MAPPING covers for Ant
Design. For the remaining 14, the call does nothing and every relative date renders in
English next to a fully translated UI.

Measured against master with the real dayjs build, starting from en each time:

language asks dayjs for locale left in effect "3 days ago" renders as
ar ca fa fi lv mi pl ro ta th tr uk its own code en 3 days ago
sr sr en 3 days ago
sr_Latn sr-latn en 3 days ago

14 of 30. With the imports added, all 30 resolve to a locale that is actually loaded:
fa 3 dies, 3 dni temu, pirms 3 dienām, пре 3 дана, 3 gün önce, and so on.

The Serbian pair needs more than an import. The two projects name the scripts the other
way around:

Cyrillic Latin
Superset catalogs sr (143,945 Cyrillic chars) sr_Latn (0)
dayjs locales sr-cyrl (404 Cyrillic chars) sr (0)

So normalizing sr → sr hands the Cyrillic catalog the Latin locale — verified:
with the imports in place but no override, the sr catalog renders pre 3 dana instead of
пре 3 дана. DAYJS_LOCALE_OVERRIDES fixes that.

The sr_Latn entry is a smaller point, stated for honesty: sr-latn is not a locale dayjs
ships, and dayjs retries the base language on a suffixed name, so sr-latn already lands on
sr (Latin) once sr is imported — correct, but by way of an undocumented retry. The entry
makes the intent explicit instead.

Finally, 'ta' is added to the Locale type in @apache-superset/core, whose own comment
says "every locale with a catalog in superset/translations" and lists the other 29.

Follows #45834, which replaced the hardcoded name map with toDayjsLocale(). That
derivation is right for 27 of the 29 codes; this adds the imports those names need, and the
one pair normalization cannot derive. Part of a short run of i18n fixes: #45953 (merged),
#45973 and #45974.

TESTING INSTRUCTIONS

The locale imports are side effects, and useLocale.test.tsx mocks both extendedDayjs and
every dayjs/locale/* module, so a unit test there can only assert the name passed to
dayjs.locale() — which is what the new toDayjsLocale test does. Proving that the locale
is really loaded needs the unmocked library:

const dayjs = require('dayjs');
dayjs.extend(require('dayjs/plugin/relativeTime'));
require('dayjs/locale/ca');
dayjs.locale('en');
console.log(dayjs.locale('ca'), dayjs().subtract(3, 'day').fromNow());
// with the import:    ca   fa 3 dies
// without the import: en   3 days ago

dayjs.locale() returning something other than what you passed is the tell.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

Developed at MYSPHERA, S.L.

🤖 Generated with Claude Code

dayjs.locale() is a no-op for a locale that was never imported: it leaves
the previous one in place and returns that instead. Only 16 of the 30
languages with a catalog were imported, so relative dates ("3 days ago")
stayed in English for the other 14, even though preamble.ts asks dayjs to
switch for all of them.

Import the 14 missing locales, and override the Serbian pair, which the
two projects name the other way around: dayjs's 'sr' is the Latin script
and 'sr-cyrl' the Cyrillic one, so normalizing the Cyrillic 'sr' catalog
would hand it Latin dates. The 'sr_Latn' entry makes the Latin mapping
explicit rather than relying on dayjs retrying the base language.

Also add 'ta' to the Locale type, which lists every other language with a
catalog.

Co-Authored-By: Claude Opus 5 <[email protected]>
@netlify

netlify Bot commented Nov 3, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 3db503a
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ae9fbf089b3c823cf507a77
😎 Deploy Preview https://deploy-preview-45982--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.

@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 6c08987edaba

@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.91%. Comparing base (9536b0a) to head (3db503a).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #45982   +/-   ##
=======================================
  Coverage   84.91%   84.91%           
=======================================
  Files        3075     3075           
  Lines      207823   207830    +7     
  Branches    48990    48992    +2     
=======================================
+ Hits       176467   176480   +13     
+ Misses      27994    27988    -6     
  Partials     3362     3362           
Flag Coverage Δ
javascript 81.23% <ø> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

@sadpandajoe
sadpandajoe requested a review from rusackas November 3, 2026 18:05

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @antalotec, LGTM! Good catch on the Serbian scripts being flipped between Babel and dayjs, that one would've been easy to miss.

@rusackas
rusackas merged commit cce45f7 into apache:master Nov 21, 2026
75 checks passed
jprinet added a commit to jprinet/superset that referenced this pull request Nov 23, 2026
* origin/master: (393 commits)
  fix(a11y): name the semantic view description input (apache#46458)
  docs(semantic): explain datasource list modification eligibility (apache#46462)
  docs(semantic-layer): document NULL-preserving exclusion filters (apache#46447)
  fix(uploads): skip folder and system entries in columnar ZIP uploads (apache#45617)
  fix(i18n-es): promote 47 of the zero-context backfill entries (apache#45847)
  fix(mcp): return structured ChartError on SQLAlchemyError in get_chart_sql (apache#44351)
  fix(datasets): follow semantic view modification permissions (apache#46448)
  fix(docker): account for container memory limits in frontend-mem-nag.sh (apache#46373)
  fix(reports): carry the report's native filters in the email and Slack link (apache#46062)
  fix(explore): apply the dataset timezone to grained temporal filter values (apache#46175)
  fix(i18n): enforce the do-not-translate registry across the catalogs (apache#45974)
  chore(logging): log unparseable virtual dataset SQL at debug in the RLS lookup (apache#46139)
  fix(i18n): split parameter-suggestion plural into two messages (apache#46049)
  test(partition-mapping): cover Hive/Impala mirrored SQL, cache outage and migration (apache#46319)
  perf(dashboard): look up the dashboard once per filter_state read (apache#46314)
  fix(i18n): load the dayjs locale for every language with a catalog (apache#45982)
  test(semantic-layer): make date export parametrization deterministic (apache#46449)
  fix(oauth2): idempotent OAuth2 completion and resilient listener (apache#40292)
  fix(explore): prevent full table scan when SQL expression is used as x-axis (apache#41339)
  feat(mcp): radar chart type plugin (apache#43571)
  ...

# Conflicts:
#	.github/workflows/docker.yml
#	.github/workflows/superset-frontend.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants