refactor: derive locale data dynamically#14815
Draft
jcfranco wants to merge 3 commits into
Draft
Conversation
jcfranco
force-pushed
the
jcfranco/7069-derive-locale-data-dynamically
branch
from
July 15, 2026 05:14
23660c6 to
94d6fa6
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors Calcite’s date/number locale handling to derive date-picker locale data dynamically via the platform Intl APIs instead of shipping/maintaining static CLDR/NLS JSON bundles. It updates related unit/E2E tests and Storybook controls to use the new locale sources.
Changes:
- Replaced date-picker’s static NLS bundle fetching + allowlist logic with lazily derived
Intl-based locale data and caching. - Updated number/locale/date tests and several component E2E tests to iterate locales from
@arcgis/toolkit/intland to usegetLocaleDatafor expectations. - Removed a large set of
date-picker/assets/nls/*.jsonlocale bundles and adjusted fixtures/types accordingly.
Reviewed changes
Copilot reviewed 68 out of 68 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/components/src/utils/number.browser.spec.ts | Switched locale iteration from date-picker NLS allowlist to toolkit supportedLocales. |
| packages/components/src/utils/locale.browser.spec.ts | Updated locale parameterization to use toolkit supportedLocales. |
| packages/components/src/utils/date.ts | Updated localized date parsing to extract numeric parts via delocalize+regex and adjusted validation. |
| packages/components/src/utils/date.browser.spec.ts | Updated date locale test data setup to use getLocaleData (Intl-derived) instead of JSON fixtures. |
| packages/components/src/components/time-picker/time-picker.browser.e2e.tsx | Updated locale list source to toolkit supportedLocales. |
| packages/components/src/components/input/input.browser.e2e.tsx | Updated locale list source to toolkit supportedLocales. |
| packages/components/src/components/input-time-picker/input-time-picker.browser.e2e.tsx | Updated locale list source to toolkit supportedLocales. |
| packages/components/src/components/input-number/input-number.browser.e2e.tsx | Updated locale list source to toolkit supportedLocales. |
| packages/components/src/components/input-date-picker/input-date-picker.e2e.ts | Replaced dynamic JSON imports with getLocaleData for localized expectations. |
| packages/components/src/components/date-picker/utils.ts | Replaced NLS-fetching implementation with lazily derived/cached Intl-based locale data. |
| packages/components/src/components/date-picker/utils.browser.spec.ts | Rewrote tests for new Intl-derived caching/normalization behavior. |
| packages/components/src/components/date-picker/assets/nls/ar.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/bg.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/bs.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/ca.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/cs.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/da.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/de.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/de-AT.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/de-CH.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/el.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/en.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/en-AU.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/en-CA.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/en-GB.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/es.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/es-MX.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/et.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/fi.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/fr.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/fr-CA.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/fr-CH.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/he.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/hi.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/hr.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/hu.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/id.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/it.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/it-CH.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/ja.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/ko.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/lt.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/lv.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/mk.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/nl.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/no.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/pl.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/pt.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/pt-BR.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/pt-PT.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/ro.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/ru.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/sk.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/sl.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/sr.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/sv.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/th.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/tr.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/uk.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/vi.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/zh-CN.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/zh-HK.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker/assets/nls/zh-TW.json | Removed static NLS locale bundle (replaced by Intl-derived data). |
| packages/components/src/components/date-picker-month/date-picker-month.tsx | Updated internal doc wording from “CLDR” to “Locale data”. |
| packages/components/src/components/date-picker-month-header/date-picker-month-header.tsx | Updated internal doc wording from “CLDR” to “Locale data”. |
| packages/components/src/components/date-picker-month-header/date-picker-month-header.e2e.ts | Updated localeData fixture shape to match new DateLocaleData interface. |
| packages/components/src/components/date-picker-month-header/date-picker-month-header.browser.e2e.tsx | Updated localeData fixture shape to match new DateLocaleData interface. |
| packages/components/.storybook/resources.ts | Updated Storybook locale control to use toolkit supportedLocales + SupportedLocale type. |
Comment on lines
+131
to
+135
| return { | ||
| placeholder, | ||
| separator: parts.find(({ type }) => type === "literal")?.value ?? "/", | ||
| unitOrder: placeholder, | ||
| }; |
Comment on lines
+155
to
+165
| function getWeekStart(locale: Locale): number { | ||
| const intlLocale = new Intl.Locale(locale) as Intl.Locale & { | ||
| getWeekInfo?: () => { firstDay: number }; | ||
| weekInfo?: { firstDay: number }; | ||
| }; | ||
| const weekInfo = intlLocale.getWeekInfo?.() ?? intlLocale.weekInfo; | ||
| if (!weekInfo) { | ||
| throw new Error(`Week information is not available for locale "${locale}"`); | ||
| } | ||
| return weekInfo.firstDay; | ||
| } |
Comment on lines
221
to
226
| it("parses arabic date", () => { | ||
| const parsed = parseDateString("٢٧/١١/٢٠٠٠", arabic as DateLocaleData); | ||
| const parsed = parseDateString("٢٧/١١/٢٠٠٠", arabic); | ||
| expect(parsed.day).toEqual(27); | ||
| expect(parsed.month).toEqual(10); | ||
| expect(parsed.year).toEqual(2000); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue: #7069
Summary
✨🧹✨
Note: this depends on Firefox 153 being the baseline for required Intl.Locale APIs.