Skip to content

fix(i18n): every date branch threads the active locale — future-relative and absolute forms localize (#4468) - #4512

Merged
yinlianghui merged 1 commit into
mainfrom
claude/issue-4468-date-locale-census
Aug 13, 2026
Merged

fix(i18n): every date branch threads the active locale — future-relative and absolute forms localize (#4468)#4512
yinlianghui merged 1 commit into
mainfrom
claude/issue-4468-date-locale-census

Conversation

@yinlianghui

Copy link
Copy Markdown
Collaborator

Closes#4468

On a zh session the same task row rendered 逾期 6 天 in one column and In 3 days in the next, with the datetime column reading 8/11/2026 12:00 am. Not a missing translation — a second locale channel that nobody was following.

1. Census — every date-formatting site the affected surfaces reach

The console list / all-views pages render date columns through getCellRenderer('date' | 'datetime') in @object-ui/fields; the same records' detail and form faces go through the read-only field widgets. Column 3 is the locale each site threaded before this PR.

#SiteBranchLocale threaded beforeDisposition
1packages/fields/src/index.tsx:824DateCellRendererrelative past, relative future, near-today, and the beyond-±7d absolute fallbackuseLocalization().locale — the tenant default only, undefined on an unconfigured workspacefixed
2packages/fields/src/index.tsx:866DateTimeCellRendererabsolute date + timenone at all — both calls passed undefinedfixed
3packages/fields/src/widgets/DateField.tsx:17 (readonly)absolute datenonefixed
4packages/fields/src/widgets/DateTimeField.tsx:17 (readonly)absolute date + timenonefixed
5packages/fields/src/widgets/FormulaField.tsx:14 (return_type: 'date')absolute datenonefixed
6packages/fields/src/widgets/GridField.tsx:400 sub-grid temporalText / displayTextabsolute date, datetimenonefixed
7packages/fields/src/index.tsx:506formatRelativeDaysrelative, both directionsoptions.locale — already correctunchanged (it was never the defect; its caller was)
8packages/fields/src/index.tsx:555formatDate default branchabsoluteoptions.locale — already correctunchanged (same: fixed by site 1)
9the overdue phrase, fields.relativeDate.overduerelative past, due-likeoptions.t → the ACTIVE UI languageunchanged — this is the half that always worked
10packages/fields/src/index.tsx:562formatDate'short' branchabsolutehardcoded 'en-US'reported, not fixed — see §5
11packages/fields/src/index.tsx:588formatDateTimeabsolutenone, and no parameter to give it onereported, not fixed — see §5
12packages/fields/src/widgets/RecordPickerDialog.tsx:863$date fallbackabsolutenonereported, not fixed — see §5

The mechanism the census exposes

There are two locale channels, and each half of a row was reading a different one:

  • the overdue phrase resolves through useFieldTranslate() → the active UI language逾期 6 天;
  • every Intl branch took its tag from useLocalization().locale — the tenant's regional default (ADR-0053), which is undefined on any workspace that never configured one. Intl reads undefined as the machine's locale, so those branches rendered en-US beside the Chinese one. A language switch moves the i18next instance and never touches that channel, which is why switching to Chinese fixed the labels and not the dates.

2. One resolver

useDisplayLocale() in @object-ui/i18n already composes both channels with a documented precedence — tenant regional default → active UI language → 'en' — and is already what every number and currency renderer uses. Every site above now resolves through it, so a date and the number beside it can no longer disagree.

Measured before adopting it, as the ruling asked:

  • The 'zh' ↔ BCP-47 mapping lives in exactly one place, and that place is this hook — because no mapping is needed. The UI language codes this renderer ships ('zh', 'ja', 'de', …) are already well-formed BCP-47 language subtags, so Intl accepts them verbatim: Intl.RelativeTimeFormat('zh', { numeric: 'auto' }).format(3, 'day') is 3天后, identical to what 'zh-CN' produces. There is no table to centralize and none was added. The card's note that 'zh-CN' is rejected by isKnownLanguage() is about the language channel's input, not about what Intl is handed.
  • The mechanism the localized half already used is the one that survives.formatRelativeDays was already Intl.RelativeTimeFormat; the overdue phrase was already t(). Neither moved. The change is entirely in which tag reaches the first one.
  • Blast radius, measured before moving anything.useDisplayLocale() is a hook, so each of the six sites had to be a component that could call it — all six are. No call site moved between modules, no exported signature changed, and the two module-private helpers that gained a locale parameter (temporalText, displayText) have three call sites, all inside GridField itself.
  • Existing pins moved: two, deliberately.GridField.test.tsx pinned its temporal expectations with bare toLocaleDateString() / toLocaleTimeString() — i.e. against the machine. They agreed with the widget only because the runner is en-US, and they would have kept agreeing after the widget started following the session, which is precisely the bug they now need to be able to see. They are spelled 'en' now — the value useDisplayLocale() resolves to with no provider — so the pin states what it means. No other existing expectation changed.

3. Red-first, per measured branch

Captured verbatim from the run against unmodified renderers, then re-measured after. Every zh case below was red before and green after; the reverse verification (reverting the five source files onto origin/main while keeping the tests) turns exactly these eight red again and nothing else.

BranchBefore (verbatim)After
future-relativeIn 3 days3天后
past-relative, non-due6 days ago6天前
near-todayToday今天
absolute, beyond ±7dSep 129月12日
absolute datetime8/11/2026 + 12:00 am2026/8/11 + 上午12:00
readonly DateField8/11/20262026/8/11
sub-grid read-only cell6/17/20262026/6/17
formula field, date8/11/20262026/8/11

4. Must-not-change — green on both sides

  • English is byte-identical.In 3 days, 6 days ago, Today, Tomorrow, Yesterday, 8/11/2026, 12:00 am — asserted as literals, and green before and after. 'en' and the runner's en-US agree on every one of these forms, which is why this is a pin rather than a hope.
  • The already-localized past/overdue branch is undisturbed: 逾期 6 天 (zh) and Overdue 6d (en) still resolve through t(), not through Intl, and the overdue cell keeps its text-red-600.
  • Channel precedence is unchanged: an explicit tenant locale still outranks the active UI language (zh chrome + tenant enIn 3 days).
  • .d.ts is byte-identical.packages/fields/dist/index.d.ts hashes f69dd0821892347bc4f8d69951ed587580046ec5ae043f1f0b8cb960853cb54f both before and after — no public surface grew, hence patch and not minor. @object-ui/i18n's diff is comment-only (a docstring in useDisplayLocale claimed DateCellRenderer "already formats from this channel" — the one thing that was not true).

One test expectation I wrote had to be withdrawn rather than made to pass, and it is worth recording: a provider-less case asserting the 'en' last resort cannot live in the new file. useObjectTranslation() outside a provider reports i18n.language from react-i18next's global instance, and every I18nProvider mounted above leaves that global on the language it was given — so a provider-less render placed after the zh cases resolves zh, and the assertion would have been about test ordering, not about the fallback. That pin lives in DateCellRenderer.test.tsx, which mounts no provider at all, and both files now say so. Filed as a repo-wide trap in the findings below.

5. Census sites deliberately NOT fixed here

  • Site 10, formatDate(…, 'short')'s hardcoded 'en-US' — its only consumers are plugin-grid/src/ObjectGrid.tsx:2778,2795, which is the ⛔ in-flight Cross-page select-all fan-out ignores the view's query under external pagination — lastFindParamsRef and the query-change reset are written only by ObjectGrid's own loader #4501 surface, and neither call site threads a locale at all. Changing the fields half alone would move nothing for any current caller; the fix has to land on both halves at once.
  • Site 11, formatDateTime — takes no options parameter, so no caller can localize it. Its only in-repo consumers are plugin-gantt/src/ObjectGantt.tsx:648,655 (and 646,653 for formatDate), which is neither a measured surface nor covered by this card's scope; adding a parameter here with nothing passing it would grow the public surface for no consumer.
  • Site 12, RecordPickerDialog's $date fallback — a MongoDB-shaped value in a lookup picker column, reachable by no test in the repo.

All three are recorded on #4272 (see below) rather than fixed on a rider.

6. Note for triage — #4272 looks like this card's twin

#4272 is open, pm:queue, undispatched, and describes the same defect from the same QA run (objectstack-ai/objectstack#7640). Its comment thread independently predicted the exact root cause measured here — DateCellRenderer reading channel 1 only, useDisplayLocale() as the resolver. This PR does not close it: #4272's stated root cause also names formatDateTime's missing parameter, which is site 11 above and is left alone on purpose. Flagging for the PM to dedupe rather than acting on it.

Verification

pnpm exec vitest run packages/fields/ → 85 files, 1348 tests, all passed
pnpm exec vitest run packages/plugin-{grid,list,detail,form,gantt,kanban,calendar,timeline}/ \
packages/mobile/ packages/i18n/ → 324 files, 3620 tests, all passed
pnpm exec vitest run packages/{components,react,collaboration}/ → 166 files, 1709 tests, all passed
pnpm exec vitest run packages/app-shell/ → 363 files, 3492 passed, 1 skipped
pnpm exec turbo run type-check --filter='...@object-ui/fields' → 54/54 successful
(prefix filter = the DOWNSTREAM consumers of @object-ui/fields)
pnpm exec turbo run lint --filter=@object-ui/fields --filter=@object-ui/i18n → 0 errors
node scripts/check-control-bytes.mjs → OK (4218 files)
node scripts/check-changeset-presence.mjs / -no-major / -fixed → all OK

Reverse verification: git checkout origin/main -- the five source files, tests kept → 8 failed | 1340 passed, the eight being exactly the zh rows in §3.


Generated by Claude Code

Date rendering had two locale channels and only one followed the user's
language: the overdue phrase resolved through the translate fn (active UI
language) while every Intl branch read the raw tenant locale, which is
undefined on an unconfigured workspace — and undefined means the MACHINE's
locale. So one row showed 逾期 6 天 beside In 3 days, and datetime columns
rendered 8/11/2026 12:00 am on a zh session.
Every date-formatting site in @object-ui/fields now resolves through the
existing useDisplayLocale() channel (tenant locale -> active UI language ->
en): DateCellRenderer, DateTimeCellRenderer, the read-only DateField /
DateTimeField / FormulaField faces, and the sub-grid's temporal cells.
English output is byte-identical and the overdue wording is untouched.
No public signature changed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Qqyix2QcnpUC9XeYVDzx3
@vercel

vercelBot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
objectuiIgnoredIgnoredAug 13, 2026 2:59am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

MetricValueBudget
Main entry (gzip)24.7 KB350 KB
Entry fileindex-CJ_ZUBa0.js
StatusPASS

📦 Bundle Size Report

PackageSizeGzipped
app-shell (index.js)9.56KB3.59KB
app-shell (runtime-config.js)7.42KB2.32KB
app-shell (types.js)0.01KB0.04KB
app-shell (urlParams.js)8.92KB3.41KB
auth (AuthContext.js)0.31KB0.24KB
auth (AuthGuard.js)1.17KB0.53KB
auth (AuthProvider.js)25.13KB5.40KB
auth (AuthShell.js)3.49KB1.40KB
auth (ForgotPasswordForm.js)12.21KB3.45KB
auth (LoginForm.js)18.13KB5.39KB
auth (PreviewBanner.js)0.90KB0.50KB
auth (RegisterForm.js)6.64KB2.21KB
auth (SocialSignInButtons.js)9.60KB3.89KB
auth (UserMenu.js)3.40KB1.22KB
auth (auth-gate-events.js)1.29KB0.66KB
auth (authStyles.js)5.04KB1.72KB
auth (createAuthClient.js)38.46KB10.17KB
auth (createAuthenticatedFetch.js)6.34KB2.43KB
auth (index.js)2.35KB1.07KB
auth (org-roles.js)6.66KB2.78KB
auth (phone-identifier.js)1.11KB0.66KB
auth (types.js)0.59KB0.35KB
auth (useAuth.js)5.02KB0.88KB
auth (useIsWorkspaceAdmin.js)1.61KB0.85KB
collaboration (CommentThread.js)26.07KB7.56KB
collaboration (LiveCursors.js)3.17KB1.27KB
collaboration (PresenceAvatars.js)6.49KB2.64KB
collaboration (PresenceProvider.js)2.79KB1.13KB
collaboration (index.js)1.65KB0.73KB
collaboration (useCollaborationTranslation.js)6.05KB2.52KB
collaboration (useCommentSearch.js)1.98KB0.88KB
collaboration (useConflictResolution.js)7.75KB1.86KB
collaboration (useMentionNotifications.js)1.81KB0.68KB
collaboration (usePresence.js)6.33KB1.84KB
collaboration (useRealtimeSubscription.js)7.91KB2.01KB
components (index.js)489.32KB108.45KB
core (index.js)3.37KB1.34KB
create-plugin (index.js)10.08KB3.26KB
data-objectstack (index.js)153.79KB41.35KB
fields (index.js)230.14KB57.12KB
i18n (LocalizationContext.js)1.76KB0.96KB
i18n (currency.js)1.22KB0.64KB
i18n (i18n.js)4.32KB1.77KB
i18n (index.js)3.35KB1.38KB
i18n (pickLocalized.js)3.69KB1.73KB
i18n (provider.js)23.12KB7.62KB
i18n (useDisplayLocale.js)2.84KB1.45KB
i18n (useObjectLabel.js)27.59KB6.63KB
i18n (useSafeTranslation.js)7.77KB3.13KB
layout (index.js)38.98KB10.85KB
mobile (MobileProvider.js)0.92KB0.49KB
mobile (ResponsiveContainer.js)0.94KB0.38KB
mobile (breakpoints.js)1.51KB0.70KB
mobile (createOfflineDataSource.js)5.61KB1.74KB
mobile (index.js)1.50KB0.62KB
mobile (offlineQueue.js)3.91KB1.35KB
mobile (pwa.js)0.97KB0.49KB
mobile (serviceWorker.js)1.48KB0.62KB
mobile (serviceWorkerSource.js)3.41KB1.48KB
mobile (useBreakpoint.js)1.54KB0.65KB
mobile (useGesture.js)6.96KB1.98KB
mobile (useOfflineSync.js)1.99KB0.72KB
mobile (usePullToRefresh.js)2.53KB0.85KB
mobile (useResponsive.js)0.71KB0.42KB
mobile (useResponsiveConfig.js)1.36KB0.63KB
mobile (useSpecGesture.js)4.32KB1.64KB
mobile (useTouchTarget.js)1.01KB0.54KB
permissions (MePermissionsProvider.js)8.75KB3.06KB
permissions (PermissionContext.js)0.31KB0.25KB
permissions (PermissionGuard.js)0.89KB0.45KB
permissions (PermissionProvider.js)3.67KB1.12KB
permissions (evaluator.js)4.41KB1.44KB
permissions (index.js)0.91KB0.41KB
permissions (store.js)0.91KB0.42KB
permissions (useFieldPermissions.js)1.28KB0.52KB
permissions (usePermissions.js)1.55KB0.71KB
plugin-ai (index.js)15.75KB3.80KB
plugin-calendar (index.js)46.86KB12.91KB
plugin-charts (index.js)62.07KB17.65KB
plugin-chatbot (index.js)181.21KB43.14KB
plugin-dashboard (index.js)120.95KB31.53KB
plugin-designer (index.js)212.58KB42.83KB
plugin-detail (index.js)239.03KB59.77KB
plugin-editor (index.js)2.46KB1.10KB
plugin-form (index.js)114.58KB27.68KB
plugin-gantt (index.js)164.14KB39.98KB
plugin-grid (index.js)188.40KB50.10KB
plugin-kanban (index.js)48.62KB13.42KB
plugin-list (index.js)111.13KB27.12KB
plugin-map (index.js)18.16KB5.81KB
plugin-markdown (index.js)13.72KB4.69KB
plugin-report (index.js)41.16KB10.96KB
plugin-timeline (index.js)26.21KB7.52KB
plugin-tree (index.js)8.50KB2.88KB
plugin-view (index.js)84.08KB20.55KB
providers (DataSourceProvider.js)0.75KB0.39KB
providers (MetadataProvider.js)1.37KB0.59KB
providers (ThemeProvider.js)1.90KB0.85KB
providers (UploadProvider.js)11.71KB3.53KB
providers (index.js)0.44KB0.22KB
providers (types.js)0.01KB0.04KB
react-runtime (index.js)5.67KB2.37KB
react (LazyPluginLoader.js)3.77KB1.33KB
react (SchemaRenderer.js)23.73KB7.96KB
react (data-invalidation.js)5.05KB2.08KB
react (index.js)1.23KB0.66KB
react (spec-input.js)0.20KB0.18KB
sdui-parser (codegen.js)4.09KB1.74KB
sdui-parser (index.js)4.47KB2.03KB
sdui-parser (parse.js)10.04KB2.82KB
sdui-parser (types.js)0.29KB0.24KB
sdui-parser (validate.js)4.69KB1.48KB
types (ai.js)0.20KB0.17KB
types (api-types.js)0.20KB0.18KB
types (app.js)2.87KB0.99KB
types (base.js)0.20KB0.18KB
types (blocks.js)0.20KB0.18KB
types (complex.js)0.20KB0.18KB
types (crud.js)0.20KB0.18KB
types (dashboard-filter-alias.js)6.23KB2.74KB
types (data-display.js)0.20KB0.18KB
types (data-protocol.js)0.20KB0.19KB
types (data.js)0.20KB0.18KB
types (designer.js)1.87KB0.85KB
types (disclosure.js)0.20KB0.18KB
types (error-code.js)1.54KB0.88KB
types (feedback.js)0.20KB0.18KB
types (field-types.js)0.20KB0.18KB
types (form.js)0.20KB0.18KB
types (http-retry.js)4.32KB2.02KB
types (index.js)3.05KB1.52KB
types (layout.js)0.20KB0.18KB
types (managed-by.js)0.19KB0.18KB
types (mobile.js)2.59KB1.31KB
types (navigation.js)0.20KB0.18KB
types (objectql.js)0.20KB0.18KB
types (overlay.js)0.20KB0.18KB
types (permissions.js)0.20KB0.18KB
types (plugin-scope.js)0.20KB0.18KB
types (record-components.js)0.20KB0.19KB
types (record-semantics.js)1.28KB0.67KB
types (registry.js)0.20KB0.18KB
types (reports.js)0.20KB0.18KB
types (spec-report.js)5.05KB1.93KB
types (system-fields.js)3.33KB1.54KB
types (theme.js)0.20KB0.18KB
types (ui-action.js)3.40KB1.71KB
types (views.js)0.20KB0.18KB
types (widget.js)0.20KB0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

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

Labels

Projects

None yet

2 participants

@yinlianghui@claude