Repository navigation
feat(i18n): InternationalizationProvider takes a calendar and exposes the resolved calendar - #9791
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC |
|---|---|---|
| Calendar | 54.6 kB (+61 B) · 9.3 kB CSS (0) | — |
| DateRangeInput | 71.4 kB (+54 B) · 11.2 kB CSS (0) | — |
| PowerSearch | 245.1 kB (+50 B) · 22.2 kB CSS (0) | — |
117 more components
| Component | Size | LoC |
|---|---|---|
| DateInput | 152.0 kB (+47 B) · 15.5 kB CSS (0) | — |
| DateTimeInput | 174.2 kB (+46 B) · 17.2 kB CSS (0) | — |
| charts/Chart | 160.4 kB (0) · 494 B CSS (0) | — |
| charts/ChartLegend | 34.4 kB (0) · 224 B CSS (0) | — |
| AlertDialog | 86.8 kB (0) · 13.1 kB CSS (0) | — |
| AppShell | 73.3 kB (0) · 12.2 kB CSS (0) | — |
| Avatar | 34.8 kB (0) · 5.4 kB CSS (0) | — |
| AvatarGroup | 37.5 kB (0) · 5.5 kB CSS (0) | — |
| AvatarGroupOverflow | 38.9 kB (0) · 5.5 kB CSS (0) | — |
| Banner | 47.3 kB (0) · 9.2 kB CSS (0) | — |
| BaseTypeahead | 55.4 kB (0) · 9.7 kB CSS (0) | — |
| BreadcrumbItem | 69.5 kB (0) · 11.3 kB CSS (0) | — |
| Breadcrumbs | 16.0 kB (0) · 3.4 kB CSS (0) | — |
| Button | 45.3 kB (0) · 8.7 kB CSS (0) | — |
| Carousel | 49.7 kB (0) · 9.5 kB CSS (0) | — |
| ChatComposer | 61.6 kB (0) · 10.6 kB CSS (0) | — |
| ChatComposerDrawer | 17.5 kB (0) · 4.7 kB CSS (0) | — |
| ChatComposerInput | 59.5 kB (0) · 10.0 kB CSS (0) | — |
| ChatComposerTokenElement | 59.5 kB (0) · 10.0 kB CSS (0) | — |
| ChatDictationButton | 45.9 kB (0) · 8.8 kB CSS (0) | — |
| ChatLayout | 48.5 kB (0) · 9.3 kB CSS (0) | — |
| ChatLayoutScrollButton | 45.8 kB (0) · 8.9 kB CSS (0) | — |
| ChatMessage | 16.7 kB (0) · 3.7 kB CSS (0) | — |
| ChatMessageList | 22.8 kB (0) · 6.9 kB CSS (0) | — |
| ChatMessageMetadata | 19.8 kB (0) · 4.1 kB CSS (0) | — |
| ChatSendButton | 45.8 kB (0) · 8.7 kB CSS (0) | — |
| ChatToolCalls | 25.9 kB (0) · 8.2 kB CSS (0) | — |
| CheckboxInput | 48.8 kB (0) · 8.7 kB CSS (0) | — |
| CheckboxList | 44.6 kB (0) · 7.5 kB CSS (0) | — |
| CheckboxListItem | 54.2 kB (0) · 10.4 kB CSS (0) | — |
| Citation | 20.1 kB (0) · 4.5 kB CSS (0) | — |
| CodeBlock | 59.2 kB (0) · 10.0 kB CSS (0) | — |
| CommandPalette | 53.5 kB (0) · 12.3 kB CSS (0) | — |
| CommandPaletteFooter | 17.0 kB (0) · 3.7 kB CSS (0) | — |
| CommandPaletteInput | 26.9 kB (0) · 7.4 kB CSS (0) | — |
| CommandPaletteList | 16.0 kB (0) · 3.4 kB CSS (0) | — |
| ComplexSelector | 55.8 kB (0) · 10.5 kB CSS (0) | — |
| ContextMenu | 75.5 kB (0) · 15.9 kB CSS (0) | — |
| DialogHeader | 48.2 kB (0) · 10.2 kB CSS (0) | — |
| DrawerHeader | 48.4 kB (0) · 11.6 kB CSS (0) | — |
| DropdownMenu | 74.2 kB (0) · 16.0 kB CSS (0) | — |
| DropdownMenuSubMenu | 58.0 kB (0) · 9.3 kB CSS (0) | — |
| Field | 42.0 kB (0) · 6.9 kB CSS (0) | — |
| FieldLabel | 38.0 kB (0) · 5.4 kB CSS (0) | — |
| FileInput | 53.9 kB (0) · 9.7 kB CSS (0) | — |
| IconButton | 45.4 kB (0) · 8.7 kB CSS (0) | — |
| InfoTip | 37.5 kB (0) · 5.0 kB CSS (0) | — |
| InputGroup | 43.1 kB (0) · 7.3 kB CSS (0) | — |
| Kbd | 16.7 kB (0) · 3.6 kB CSS (0) | — |
| LayerProvider | 63.4 kB (0) · 9.4 kB CSS (0) | — |
| Lightbox | 52.6 kB (0) · 9.1 kB CSS (0) | — |
| Link | 42.8 kB (0) · 6.9 kB CSS (0) | — |
| ListItem | 53.5 kB (0) · 10.4 kB CSS (0) | — |
| Markdown | 146.2 kB (0) · 18.8 kB CSS (0) | — |
| MetadataList | 16.7 kB (0) · 3.8 kB CSS (0) | — |
| MobileNav | 54.4 kB (0) · 9.3 kB CSS (0) | — |
| MobileNavToggle | 45.7 kB (0) · 8.7 kB CSS (0) | — |
| MoreMenu | 74.4 kB (0) · 16.0 kB CSS (0) | — |
| MultiSelector | 73.2 kB (0) · 15.3 kB CSS (0) | — |
| NumberInput | 55.2 kB (0) · 10.2 kB CSS (0) | — |
| Outline | 22.2 kB (0) · 4.2 kB CSS (0) | — |
| Pagination | 88.1 kB (0) · 16.5 kB CSS (0) | — |
| Popover | 52.1 kB (0) · 12.8 kB CSS (0) | — |
| RadioList | 43.5 kB (0) · 6.9 kB CSS (0) | — |
| RadioListItem | 52.0 kB (0) · 9.4 kB CSS (0) | — |
| ResizeHandle | 19.5 kB (0) · 4.3 kB CSS (0) | — |
| SegmentedControl | 82.9 kB (0) · 6.7 kB CSS (0) | — |
| Selector | 79.3 kB (0) · 16.2 kB CSS (0) | — |
| SideNav | 73.7 kB (0) · 10.1 kB CSS (0) | — |
| SideNavCollapseButton | 46.2 kB (0) · 8.8 kB CSS (0) | — |
| SideNavHeading | 59.9 kB (0) · 10.0 kB CSS (0) | — |
| SideNavItem | 54.9 kB (0) · 9.8 kB CSS (0) | — |
| Slider | 91.1 kB (0) · 8.3 kB CSS (0) | — |
| Spinner | 18.5 kB (0) · 5.7 kB CSS (0) | — |
| Step | 28.3 kB (0) · 5.6 kB CSS (0) | — |
| Stepper | 46.9 kB (0) · 8.9 kB CSS (0) | — |
| Switch | 88.6 kB (0) · 9.5 kB CSS (0) | — |
| Table | 84.9 kB (0) · 16.6 kB CSS (0) | — |
| TableCell | 76.7 kB (0) · 16.3 kB CSS (0) | — |
| TableHeaderCell | 76.3 kB (0) · 16.1 kB CSS (0) | — |
| TableSelectionToolbar | 54.9 kB (0) · 11.8 kB CSS (0) | — |
| TabList | 35.5 kB (0) · 6.4 kB CSS (0) | — |
| TabMenu | 56.6 kB (0) · 9.9 kB CSS (0) | — |
| TextArea | 48.2 kB (0) · 8.8 kB CSS (0) | — |
| TextInput | 53.1 kB (0) · 9.9 kB CSS (0) | — |
| Thumbnail | 49.7 kB (0) · 10.3 kB CSS (0) | — |
| TimeInput | 138.2 kB (0) · 14.5 kB CSS (0) | — |
| Toast | 59.7 kB (0) · 9.0 kB CSS (0) | — |
| ToggleButton | 46.2 kB (0) · 8.8 kB CSS (0) | — |
| Token | 25.8 kB (0) · 4.8 kB CSS (0) | — |
| Tokenizer | 70.1 kB (0) · 17.1 kB CSS (0) | — |
| Toolbar | 34.8 kB (0) · 7.9 kB CSS (0) | — |
| TopNav | 56.0 kB (0) · 9.6 kB CSS (0) | — |
| TopNavHeading | 59.3 kB (0) · 9.8 kB CSS (0) | — |
| TopNavMegaMenu | 54.4 kB (0) · 10.6 kB CSS (0) | — |
| TopNavMenu | 59.2 kB (0) · 9.9 kB CSS (0) | — |
| TreeList | 39.6 kB (0) · 5.3 kB CSS (0) | — |
| Typeahead | 63.3 kB (0) · 11.2 kB CSS (0) | — |
| lab/ChatEmojiPicker | 66.0 kB (0) · 773 B CSS (0) | — |
| lab/ChatReactionBar | 66.5 kB (0) · 1.1 kB CSS (0) | — |
| lab/ChatTypingIndicator | 24.8 kB (0) · 612 B CSS (0) | — |
| lab/CommentComposer | 104.9 kB (0) · 1.9 kB CSS (0) | — |
| lab/CommentPin | 47.1 kB (0) · 1.2 kB CSS (0) | — |
| lab/Comments | 265.4 kB (0) · 2.5 kB CSS (0) | — |
| lab/CommentThread | 260.1 kB (0) · 2.4 kB CSS (0) | — |
| lab/DiffViewer | 71.4 kB (0) · 2.1 kB CSS (0) | — |
| lab/EmojiPicker | 70.8 kB (0) · 722 B CSS (0) | — |
| lab/ListInput | 82.0 kB (0) · 1.6 kB CSS (0) | — |
| lab/SelectableCardGroup | 50.5 kB (0) · 162 B CSS (0) | — |
| lab/TourStep | 58.0 kB (0) · 590 B CSS (0) | — |
| lab/TransferList | 75.9 kB (0) · 1.7 kB CSS (0) | — |
| lab/TransferListSelector | 83.5 kB (0) · 1.9 kB CSS (0) | — |
| richtext/RichTextEditor | 278.4 kB (0) · 2.6 kB CSS (0) | — |
| richtext/RichTextEditorToolbar | 228.8 kB (0) · 454 B CSS (0) | — |
| richtext/RichTextView | 258.9 kB (0) · 2.3 kB CSS (0) | — |
| Timestamp | 21.3 kB (−5 B) · 8.9 kB CSS (0) | — |
| lab/Schedule | 60.7 kB (−5 B) · 3.9 kB CSS (0) | — |
Package size: @astryxdesign/core 6.44 MB packed (+10.9 kB); no new dependencies.
API changes: core +4 · ~0 · −0
Committed API report behind this build: cli 8 rows, core 2 rows; run pnpm api:report.
4 API changes (advisory)
| Package | Where | Signature | Usage | |
|---|---|---|---|---|
| + | core |
. · Components · component InternationalizationProvider |
prop calendar?: CalendarSystem |
<InternationalizationProvider calendar={…} /> |
| + | core |
. · Types · type CalendarSystem |
type CalendarSystem = 'gregory' | 'iso8601' | 'buddhist' | 'roc' | 'japanese' | 'persian' | 'indian' | 'hebrew' | 'chinese' | 'dangi' | 'coptic' | 'ethiopic' | 'ethioaa' | 'islamic-c … #85e5f84c |
import type {CalendarSystem} from '@astryxdesign/core' |
| + | core |
. · Types · interface InternationalizationContextValue |
calendar?: CalendarSystem |
import type {InternationalizationContextValue} from '@astryxdesign/core'; const x: InternationalizationContextValue = {calendar: …} |
| + | core |
./i18n · Also exported from an earlier entry point · CalendarSystem |
CalendarSystem (.) |
import {CalendarSystem} from '@astryxdesign/core/i18n' |
Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Approval waits on an engineering owner's spec decision. The calendar prop on InternationalizationProvider, the calendar context field, the exported CalendarSystem type, and the rewrites of INV10 and of the provider record's FR8, FR10 and ORD3 all rest on spec:AST-111 FR1, FR2 and FR5, which are still a draft and are not on main. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request; the author may do so if they are an engineering owner.
Whatever that decision, two fixes are needed:
- The changeset, the
calendarprop JSDoc and the provider doc say calendars that needTemporalresolve to Gregorian and warn when it is missing, but the provider puts the requested calendar on the context unchanged and warns nothing, so reword them to say the fallback applies when a date component resolves the calendar. utcMidnightandformatToPartsinpackages/core/src/utils/calendarSystem.tscopy the date-only path ofplainDateFormatinplainDate.tsand already drop thetimeZoneand time-of-day options thatplainDateFormathonours, so export one shared helper fromplainDate.tsand call it instead.
[Automated review]
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [feat] InternationalizationProvider takes a `calendar` prop (`CalendarSystem`, exported from `@astryxdesign/core/i18n`), such as `'persian'`, `'hebrew'`, `'islamic-umalqura'`, or `'buddhist'`, and exposes the resolved calendar on `InternationalizationContext` as `calendar`. A `-u-ca-` keyword in the provider locale, such as `th-TH-u-ca-buddhist`, selects one too; a locale alone never changes the calendar, so `fa-IR` resolves to Gregorian until you set `calendar="persian"`. An unknown identifier resolves to Gregorian and warns once in development. The Gregorian-aligned calendars (`gregory`, `iso8601`, `buddhist`, `roc`, `japanese`) work everywhere; the others need `Temporal`, and without it they resolve to Gregorian and warn once in development. Astryx date components keep showing Gregorian dates, and date values stay Gregorian ISO strings. |
There was a problem hiding this comment.
This says calendars that need Temporal "resolve to Gregorian and warn once in development" when it is missing. The provider puts the requested calendar on the context unchanged and warns nothing; the PR's own the provider accepts %s test expects 'persian' with Temporal removed. Suggest saying that the context carries the requested calendar, and that the Gregorian fallback and its warning apply when a date component resolves it. The prop JSDoc and the provider doc entry need the same change.
| function utcMidnight(pd: PlainDate): number { | ||
| const date = new Date(0); | ||
| date.setUTCFullYear(pd.year, pd.month - 1, pd.day); | ||
| return date.getTime(); | ||
| } | ||
|
|
||
| function formatToParts( | ||
| calendar: CalendarSystem, | ||
| pd: PlainDate, | ||
| options: Intl.DateTimeFormatOptions, | ||
| locale: Locale, | ||
| ): Intl.DateTimeFormatPart[] { | ||
| return dateTimeFormatFor(locale, { | ||
| ...options, | ||
| calendar, | ||
| timeZone: 'UTC', | ||
| }).formatToParts(utcMidnight(pd)); | ||
| } |
There was a problem hiding this comment.
These copy plainDate.ts's private utcTime and the date-only branch of plainDateFormat (dateTimeFormatFor(locale, {...options, calendar, timeZone: 'UTC'}) over UTC midnight), and they already differ: plainDateFormat honours timeZone and time-of-day options, while this always forces UTC. Exporting one parts-returning helper from plainDate.ts that shares plainDateFormat's branch selection, and calling it from formatCalendarDate, keeps one path.
| // Intl has no month names for `iso8601`. It drops the month or orders the | ||
| // fields oddly, so labels use `gregory`, which has the same months and days. |
There was a problem hiding this comment.
Non-blocking: this sentence carries two topics and a vague word. Suggested:
// Intl has no month names for `iso8601`. Labels use `gregory`, which has the same months and days.20438bb to
158af09
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's spec decision. The calendar prop on InternationalizationProvider, the calendar context field, the exported CalendarSystem type, and the rewrites of INV10 and of the provider record's FR8, FR10 and ORD3 all rest on spec:AST-111 FR1, FR2 and FR5, which are still a draft and are not on main. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request; the author may do so if they are an engineering owner.
The Temporal-fallback wording and the copied date-only formatting path from the last review are fixed; one fix is still needed whatever the decision:
formatDayNumberand its cache inpackages/core/src/utils/calendarSystem.ts(lines 380-401) copyplainDateFormatDayNumberinplainDate.ts, which Calendar's day cells already use, so give the shared helper an optionalnumberingSystem, call it fromformatCalendarDate, and drop the raw-Intllint allowlist, README and Owning code entries that exist only for the copy.
[Automated review]
| const dayNumberFormats = new Map<string, Intl.NumberFormat>(); | ||
|
|
||
| /** | ||
| * A day of the month written in the locale's digits, such as ۸ in `fa`, or in | ||
| * the given numbering system. | ||
| */ | ||
| export function formatDayNumber( | ||
| day: number, | ||
| locale: Locale, | ||
| numberingSystem?: string, | ||
| ): string { | ||
| const key = `${locale}|${numberingSystem ?? ''}`; | ||
| let format = dayNumberFormats.get(key); | ||
| if (format == null) { | ||
| format = new Intl.NumberFormat(locale, { | ||
| useGrouping: false, | ||
| numberingSystem, | ||
| }); | ||
| dayNumberFormats.set(key, format); | ||
| } | ||
| return format.format(day); | ||
| } |
There was a problem hiding this comment.
This copies plainDateFormatDayNumber in plainDate.ts (the same new Intl.NumberFormat(locale, {useGrouping: false}) behind a module-level cache), which Calendar's day cells and MonthScroller already call. Giving the shared helper an optional numberingSystem and calling it from formatCalendarDate keeps one path for day digits, and the raw-Intl allowlist, README and Owning code entries for this file are then no longer needed.
| // The subset of the Temporal API that this module reads. It is declared here | ||
| // so that the published types do not need the `esnext.temporal` library. |
There was a problem hiding this comment.
Non-blocking: "It is declared here" is passive. Suggested:
// The published types must not need the `esnext.temporal` library.
// This module declares only the Temporal members it reads.| : undefined; | ||
| } | ||
|
|
||
| // Keyed by the Temporal object, so a polyfill loaded later is probed again. |
There was a problem hiding this comment.
Non-blocking: passive wording. Suggested:
// The key is the Temporal object, so a polyfill that loads later gets its own probe.… the resolved calendar Add the calendar-system utility, the provider's calendar prop and its resolution, the context field, and the raw-Intl lint allowance for day digits. Astryx date components still show Gregorian dates.
… formatter path The provider keeps the requested calendar on the context, and a date component that resolves it falls back to Gregorian where Temporal is missing; the changeset, the prop docs, and INV10 now say so. Calendar labels take their parts from plainDateFormatToParts, which shares plainDateFormat's formatter and date, instead of a copy of its date-only path.
…yNumber plainDateFormatDayNumber takes an optional numbering system, and formatCalendarDate calls it instead of its own NumberFormat cache. calendarSystem.ts no longer calls Intl directly, so it leaves the raw-Intl allowlist and the Owning code formatter list.
158af09 to
4c4fb22
Compare
The provider resolves its calendar from its calendar prop, else gregory. A locale such as th-TH-u-ca-buddhist shows Gregorian dates on the latest release, so honoring the keyword would change output with no code change. The keyword lookup and the islamic alias go; calendar="islamic" now resolves to gregory with the unknown-identifier warning.
There was a problem hiding this comment.
Approval waits on an engineering owner's spec decision. The calendar prop on InternationalizationProvider, the calendar context field, the exported CalendarSystem type and the rewrites of INV10 and of the provider record's FR8, FR10 and ORD3 rest on draft spec:AST-111 (#9605), which is not on main, and its latest FR2 no longer lets a -u-ca- keyword or the islamic alias select the calendar, as this head does. An engineering owner records the decision, including whether a -u-ca- keyword selects the calendar, by commenting /approve-spec <full head SHA> on this pull request; the author may do so if they are an engineering owner.
Whatever that decision, two fixes are needed:
- Miss:
plainDateFormatToPartsinpackages/core/src/utils/plainDate.ts(lines 473-477) is a new helper whoselocaledefaults to'en', which INV9 rules out for new pure helpers, so makelocalerequired, as both callers already pass it. - Miss:
isInCalendarMonthinpackages/core/src/utils/calendarSystem.ts(lines 268-276) rebuilds the inclusive range check thatplainDateIsInRangeinplainDate.tsalready provides and Calendar's day cells use, so call the shared helper instead.
[Automated review]
| export function plainDateFormatToParts( | ||
| pd: PlainDate, | ||
| options: Intl.DateTimeFormatOptions, | ||
| locale: Locale = 'en', |
There was a problem hiding this comment.
Miss: this new helper defaults locale to 'en'. INV9 says new pure helpers require an explicit locale, and the raw-Intl lint does not check this helper, so a caller that leaves it out shows English silently. Both callers already pass it:
locale: Locale,| return ( | ||
| !plainDateIsBefore(pd, month.start) && !plainDateIsAfter(pd, month.end) | ||
| ); |
There was a problem hiding this comment.
Miss: this rebuilds the inclusive range check that plainDateIsInRange in plainDate.ts already provides, and Calendar's day cells call that helper. Calling it keeps one path:
return plainDateIsInRange(pd, [month.start, month.end]);There was a problem hiding this comment.
Approval waits on an engineering owner's spec decision. The calendar prop on InternationalizationProvider, the calendar context field, the exported CalendarSystem type, the calendar utility and the rewrites of INV10 and the provider record's FR10 and ORD3 rest on the AST-111 calendar-systems spec, which is still a draft in #9605; this head now follows that draft, including that a -u-ca- keyword never selects the calendar. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner. These need a fix whatever the decision:
- Miss:
plainDateFormatToParts(packages/core/src/utils/plainDate.ts:476) defaultslocaleto'en', but INV9 requires new pure helpers to take an explicit locale, so make the parameter required. - Miss:
isInCalendarMonth(packages/core/src/utils/calendarSystem.ts:269-276) rebuilds the range check thatplainDateIsInRangealready provides, so returnplainDateIsInRange(pd, [month.start, month.end])instead. - Regression: the provider record's Owns line (
docs/specs/components/i18n/InternationalizationProvider.spec.md:75) still says the calendar resolves fromcalendarandlocale, which contradicts FR10 and ORD3 now that the keyword step is gone.
[Automated review]
| - Resolving the subtree's calendar system from `calendar` and `locale`, and | ||
| exposing it on the context. |
There was a problem hiding this comment.
Regression: this still names locale as a calendar input, but FR10 and ORD3 below now say a locale never selects the calendar. Suggested:
- Resolving the subtree's calendar system from `calendar`, and
exposing it on the context.
…inDateIsInRange The provider record's ownership line no longer names the locale as a calendar input.
|
/approve-spec 8f6918e |
There was a problem hiding this comment.
Approved pending CI: one test shard was still running on this head, so wait for CI to pass before landing.
The calendar prop on InternationalizationProvider, the calendar context field and the CalendarSystem type follow the provider and internationalization records, which an engineering owner approved for this exact head. The latest commit fixes the three issues raised earlier: plainDateFormatToParts now requires its locale, isInCalendarMonth reuses plainDateIsInRange, and the provider record no longer names locale as a calendar input.
Two optional follow-ups:
- FR8 now says a nested provider replaces
calendar, but no test covers it; a parentcalendar="persian"with a child provider that omits it, expecting'gregory', would guard it. - The
useCalendarSystem.tsheader says date components read the hook, but none does yet.
[Automated review]
| * @position Internal i18n hook; read by InternationalizationProvider and date | ||
| * components. Not re-exported from the i18n barrel. |
There was a problem hiding this comment.
Non-blocking: the provider imports only resolveCalendarSystem, and no date component imports this file yet. Suggested:
* @position Internal i18n hook. The provider imports resolveCalendarSystem.
* Not re-exported from the i18n barrel.| | FR5 | The provider MUST NOT set DOM `lang` or `dir`. Its direction value and the application's DOM direction are separate inputs the application keeps aligned. | `architecture:internationalization/INV12` | settled | | ||
| | FR6 | Without a provider, the public context and hooks MUST expose locale `en`, direction `ltr`, an empty supplied-catalog map, and a translator backed by shipped English. | Released context and tests | settled | | ||
| | FR7 | The provider MUST preserve a string-returning translator suitable for visible and assistive attributes. | Released catalog/runtime contract | settled | | ||
| | FR8 | A nested provider MUST replace locale, messages, overrides, direction, and calendar with values derived solely from the child provider's own props rather than merge parent context. | Released provider and nested-provider tests | settled | |
There was a problem hiding this comment.
Non-blocking: FR8 now covers calendar, but its verification row still names only messages, overrides and direction, and no test renders a nested provider with a calendar. A case with a parent calendar="persian" and a child provider that omits it, expecting 'gregory', would guard this.
This implements the provider and shared-utility part of
spec:AST-111(approved in #9605): FR1 and FR2 forInternationalizationProvider, the FR5 fallback that date components use, and the calendar-system utility that later PRs read.User need
Applications that serve people who use another calendar need one place to say which calendar their dates are in, separately from language. A locale alone can't say it:
fa-IRusers don't all want the Persian calendar, and a Thai app may want Buddhist years while its locale staysen. Without a provider-level calendar, every date component would need its own prop and its own resolution rules.Problem and solution fit
InternationalizationProvidertakescalendar?: CalendarSystem. Without it, the calendar is Gregorian. A locale never selects one, even with a-u-ca-keyword: honoring the keyword would change released output with no code change, so it waits for a later minor release.InternationalizationContextascalendar.gregoryand warns once in development.calendar="islamic"is not a supported identifier, so it resolves togregorywith that warning.i18n/useCalendarSystem.ts, internal): a component resolves its owncalendarprop, then the provider's, thengregory. WhereTemporalis missing, a calendar outside the Gregorian-aligned set resolves togregorywith one development warning per calendar. The context keeps the requested calendar.utils/calendarSystem.ts): calendar months located by their Gregorian days, month and year steps, dates from calendar fields, months in a year, availability of each calendar, labels and locale digits.Temporaldoes the arithmetic for every calendar whose months are not Gregorian; Gregorian-aligned calendars never touch it.temporal-polyfill(a dev dependency, imported only by tests);plainDate.ts: acalendarparameter onplainDateFormatStandaloneMonthYear(defaultgregory), an internalplainDateFormatToPartsfrom the same formatter asplainDateFormat, with a requiredlocale, and an optionalnumberingSystemonplainDateFormatDayNumber, which the utility uses to write day numbers.Current specification
spec:AST-111FR1, FR2 and FR5 (approved in spec(AST-111): date components use the calendar the application chooses #9605).architecture:internationalizationINV10 states that the application selects the calendar, that values stay Gregorian ISO, and theTemporalboundary. It also states that Astryx date components show Gregorian dates.component:InternationalizationProvideradds thecalendarconcept, FR10, ORD3 and the FR10 verification row, addscalendarto FR8's nested-provider rule, and linksspec:AST-111FR1 and FR2.AST-111 is still a draft, so this PR waits for its approval.
Public delta and caller burden
CalendarSystem, exported from@astryxdesign/core/i18n:gregory,iso8601,buddhist,roc,japanese,persian,indian,hebrew,chinese,dangi,coptic,ethiopic,ethioaa,islamic-civil,islamic-tbla,islamic-umalqura.InternationalizationProvidercalendar?: CalendarSystem;InternationalizationContextValuecalendar?: CalendarSystem.Design and alternatives
TemporalfromglobalThis, so published types don't need theesnext.temporallibrary and Gregorian applications load nothing.Temporalavailability resolve the same calendar.Evidence
-u-ca-locale stays Gregorian, also under a providercalendar), every identifier, an unknown identifier andislamic, barefa-IRandth-TH, a calendar independent of language, and the no-Temporalfallback with its once-per-calendar warning, including aTemporalthat lacks the calendar.Temporalcalendar from 1900 through 2100.calendarDateFromFieldsrejects dates a calendar does not have (30 Esfand in a common year) instead of adjusting them.plainDateFormatToPartsjoins to theplainDateFormattext, andplainDateFormatDayNumberwrites a given numbering system's digits.Scope
Testing
--maxWorkers=2, over the test files beside the changed sources (utils and i18n) plusdocPropLiterals: 55 files, 951 of 952 tests passed. The one failure,hitArea.test.ts"batches every pending control into one frame: all reads, then all writes", fails the same way on themaincommit the stack sits on (d23d1fe438).pnpm exec tsc --noEmit -p packages/core: passes.pnpm check:knowledge,pnpm check:changesets: pass.node scripts/pre-review.mjs --base main: 1,337 authored lines.Writing rubric results
architecture:internationalizationTemporalboundary and the Gregorian components in the present tense.component:InternationalizationProvidercalendarconcept, FR10 and ORD3 are present tense and claim only resolution and the context field. The Owns line names onlycalendaras the calendar's source, as FR10 and ORD3 do.