Skip to content

fix: fall back to the default locale when formatting with an unknown locale - #1800

Open
abhijeet117 wants to merge 1 commit into
moment:masterfrom
abhijeet117:fix/unknown-locale-default-fallback
Open

fix: fall back to the default locale when formatting with an unknown locale#1800
abhijeet117 wants to merge 1 commit into
moment:masterfrom
abhijeet117:fix/unknown-locale-default-fallback

Conversation

@abhijeet117

Copy link
Copy Markdown

Summary

Formatting a DateTime with an unsupported locale option fell back to the system locale instead of Settings.defaultLocale, because Intl silently resolves unknown locales to the system one. Following the discussion in #1366, the default locale is now passed to Intl as a backup locale when it differs from the requested one, so Intl prefers it over the system locale. The formatter cache key includes the locales list, so changes to Settings.defaultLocale take effect immediately.

Testing

Reproduced on master: with Settings.defaultLocale = "fr", dt.toFormat("LLLL", { locale: "zz" }) returned the system-locale month name instead of "mai". Added regression tests in toFormat.test.js covering the fallback and the behavior after changing Settings.defaultLocale. The full jest suite matches the clean-master baseline on Windows, with both new tests passing.

Checklist

  • Bug reproduced before fix
  • Root cause identified
  • Bug fixed
  • Tests passed

Fixes #1366

@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 25, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: abhijeet117 / name: abhijeet117 (56f1e5c)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

toFormat with unknown locale defaults to system locale instead of Luxon settings defaultLocale

1 participant