Skip to content

fix(i18n): localize Timestamp relative formats - #5859

Merged
nynexman4464 merged 2 commits into
mainfrom
nynexman4464/fix/timestamp-relative-locale
Sep 2, 2026
Merged

fix(i18n): localize Timestamp relative formats#5859
nynexman4464 merged 2 commits into
mainfrom
nynexman4464/fix/timestamp-relative-locale

Conversation

@nynexman4464

@nynexman4464 nynexman4464 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Problem

Timestamp's absolute formats follow InternationalizationProvider, but relative, relative_short, and the relative branch of auto still assemble English phrases manually. A French provider therefore renders 2 hours ago, now, and yesterday in English.

Change

  • Preserve Timestamp's existing second/minute/hour/day/month/year thresholds and future-clock-skew handling.
  • Format the selected value and unit with the provider locale through Intl.RelativeTimeFormat.
  • Use the native long style for relative/auto and narrow for relative_short.
  • Keep long-form now and yesterday idioms, while compact output stays numeric.
  • Cache formatters by locale, style, and numeric mode.
  • Add the pure formatter to the strict raw-Intl infrastructure boundary.

Native formatting also replaces the English-only in a few seconds special case with the locale's exact seconds form, such as in 31 seconds.

Intl.RelativeTimeFormat formats a signed quantity and unit; it has no calendar option and does not convert or inspect calendar dates. Gregorian enforcement therefore does not apply here. The raw-Intl lint did catch direct construction in Timestamp.tsx; construction now lives in a narrowly approved pure helper that requires the provider locale.

Visual evidence

The permanent English Storybook story covers every past and future transition point. French below is a temporary provider override used only for evidence.

Before — French provider ignored

Before: every relative label remains English under a French provider

After — English

After: English relative labels at every transition point

After — French

After: French relative labels at every transition point

Fixes #5074.

Test plan

  • Regression proof against the old implementation: three new provider-locale cases failed with English output (2 hours ago, 2h ago, and now) where French was expected.
  • pnpm exec vitest run --project ui packages/core/src/Timestamp/Timestamp.test.tsx — 92 passed.
  • pnpm exec vitest run --project node internal/eslint-plugin-astryx/no-raw-intl-locale.test.mjs — 100 passed.
  • Permanent Storybook story: English past/future transition points at present, seconds, minutes, hours, days, months, and years.
  • pnpm rtl:audit --filter Timestamp — verified N/A with 0 coverage gaps; Timestamp has no directional visual or behavior.
  • pnpm lint:strict — passed with existing warnings only.
  • pnpm -F @astryxdesign/core build — passed.

@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 2, 2026 8:16pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 1, 2026
@nynexman4464
nynexman4464 force-pushed the nynexman4464/fix/timestamp-relative-locale branch from 67763cd to 4257c1b Compare September 1, 2026 22:51
github-actions Bot added a commit that referenced this pull request Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

Preview availability: Storybook and Sandbox were not published for this CI run.

Modified Components

Timestamp (@astryxdesign/core)
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 643 -
Complexity N/A Very High (44) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.8KB 1.2KB

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

Timestamp - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/20 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Visual Regression

12 added · 0 removed. View the report

A repository maintainer can accept these exact frames: /accept-visual 33568304679/1 <why every changed frame is correct>

Added — After
Added — After visual regression frame

Added — After
Added — After visual regression frame

Added — After
Added — After visual regression frame


Generated by PR Enrichment workflow | View full report

@nynexman4464
nynexman4464 marked this pull request as ready for review September 1, 2026 23:56

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks this is good. The provider-locale regression is fixed across relative, compact, and auto modes. Please resolve the generated RTL-audit list conflict before merge.

[Reviewed by Robohands]

@nynexman4464
nynexman4464 enabled auto-merge (squash) September 2, 2026 18:32
@nynexman4464

Copy link
Copy Markdown
Contributor Author

/accept-visual 33568304679/1 screens look good, test is essentially plain default text

github-actions Bot added a commit that referenced this pull request Sep 2, 2026
@github-actions github-actions Bot added the visual-approved Current visual bundle has an explicit acceptance record label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Visual changes accepted for 4257c1b81d6a. A new push invalidates this approval; after merge, the reviewed AFTER frames must reproduce before the baseline is promoted.

@github-actions github-actions Bot removed the visual-approved Current visual bundle has an explicit acceptance record label Sep 2, 2026
@nynexman4464
nynexman4464 merged commit 6949d4b into main Sep 2, 2026
24 of 25 checks passed

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, this is good. Non-English providers now get native relative timestamps across relative, compact, and auto modes, and the merge resolves the RTL-audit conflict.

[Reviewed by Robohands]

@github-actions
github-actions Bot deleted the nynexman4464/fix/timestamp-relative-locale branch September 3, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InternationalizationProvider locale is ignored by calendar, date/time, Timestamp, and PowerSearch formatting

2 participants