Skip to content

fix(ui): localise the route table's age and make its tooltips keyboard-reachable - #614

Merged
jsenecal merged 4 commits into
mainfrom
fix/605-age-locale-tooltips
Nov 25, 2026
Merged

jsenecal merged 4 commits into
mainfrom
fix/605-age-locale-tooltips

Conversation

@jsenecal

Copy link
Copy Markdown
Collaborator

Closes #605

The route table's Age column was always English. Its tooltip and the Weight tooltip could only be opened with a mouse.

Locale. A new web.locale setting (default en) takes a BCP 47 tag made of a language, an optional script and an optional region, such as fr, pt-BR or zh-Hant-TW. Anything else is rejected at startup: the browser throws on a malformed tag, and the UI loads a file named after it.

  • Relative age. The age (2 hours) still comes from dayjs, now in the matching dayjs locale.
    • The locale file is loaded on demand with a dynamic import, which webpack splits into one small chunk per locale, so only the configured one is fetched.
    • The lookup tries the full tag, then drops subtags. dayjs has no script locales, so it also tries language-region without the script: pt-BR loads pt-br, zh-Hant-TW loads zh-tw, de-LU loads de.
    • A language dayjs has no file for is permanent (MODULE_NOT_FOUND from webpack's context module): it is cached as English and warned about once per page load. Any other failure, such as a ChunkLoadError, stops the lookup without caching, so the next mount retries the same locale.
    • The age shows in English until the file has loaded.
  • Tooltip time. It is formatted with Intl.DateTimeFormat([locale, 'en'], ...), so an unknown locale falls back to English, not the browser's language. It uses fixed options: short weekday, date, 24-hour time (hourCycle: 'h23'), in UTC with the zone name. In English it reads Tue, Nov 24, 2026, 08:00:00 UTC, against Tue, 24 Nov 2026 08:00:00 UTC before: still English, 24-hour and UTC, with the month before the day. The CHANGELOG says so.
  • Copied table. It uses the same formatter (util/age.ts), so the copied text matches the cells.

Tooltips. Age and Weight use a new FocusableTooltip, following the Marker pattern from #581: a focusable span with a focus ring and closeOnClick={false}. It opens on keyboard focus and stays open after a tap.

  • Chakra sets aria-describedby on its trigger only while the tooltip is open, and clears it while closed. So the text carries its own aria-describedby pointing at a visually hidden copy of the label, and the tooltip wraps both, with focus and pointer events reaching it by bubbling.
  • Screen readers therefore get the time or the weight hint whether or not the tooltip is open, and when reading the table without moving focus.
  • The focus ring is the theme's 3px outline shadow. It sits inside the cell's 16px padding, so the table body's overflow-x: hidden doesn't clip it.

Also updated: the config model, the UI Config type, the regenerated UI fixture, the sample config, the docs (web-ui and complete-config) and the CHANGELOG.

Tests (Vitest). Time zone pinned with vi.stubEnv('TZ', ...) to a zone that isn't UTC, and only Date faked. They cover:

  • the English default as a literal string, and French for both the age and the tooltip;
  • a 12-hour locale (en-US) keeping the 24-hour clock;
  • the [locale, 'en'] fallback, the de-LU → de fallback, and zh-Hant-TW actually loading the zh-tw file (2 小時);
  • a missing locale cached as English with a single warning, and a failed chunk download retried rather than cached;
  • keyboard focus and tap for both tooltips, and the accessible description while the tooltip is closed;
  • the copied table in English and French.

Tests (pytest). The default value, and which tags are accepted and rejected.

I also ran a local next build to confirm the locale files land in separate lazy chunks and not in _app.

…d-reachable

Add web.locale (BCP 47 language, script and region; default en). The
Age column formats the relative age with the matching dayjs locale,
loaded on demand as its own chunk, falling back to the language and
then English, and the tooltip's UTC time with Intl.DateTimeFormat in
that locale.

The Age and Weight tooltips now sit on a focusable trigger, like the
markers from #581, so they open on keyboard focus and stay open on tap.

Closes #605
…d table

The age tooltip gets its own Intl options (weekday, date, 24-hour time,
UTC) instead of the cached-time defaults, and asks for [locale, 'en'] so
an unknown locale falls back to English rather than the browser's. The
copied table uses the same formatting as the cells.

dayjs locale lookup also tries language-region without the script
(zh-Hant-TW loads zh-tw), and only a successful load is cached, so a
failed chunk is retried.

FocusableTooltip gives screen readers the tooltip text as a permanent
visually hidden description, since Chakra only sets aria-describedby
while the tooltip is open.

Refs #605
…load

A locale file the bundle doesn't have (MODULE_NOT_FOUND from webpack's
context, ERR_MODULE_NOT_FOUND under Node) is permanent: cache English
for the tag and warn once per page load. Any other failure, such as a
ChunkLoadError, stops the lookup without caching so the next mount
retries the same locale.

Refs #605
@github-actions github-actions Bot added docs Improve documentation backend Python backend: API, models, state, execution frontend Next.js UI and the runtime UI build labels Nov 24, 2026
@coveralls

coveralls commented Nov 24, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 89.22% (+0.02%) from 89.198% — fix/605-age-locale-tooltips into main

@jsenecal
jsenecal marked this pull request as ready for review November 25, 2026 21:48
@jsenecal
jsenecal requested a review from WilhelmZA November 25, 2026 21:48

@WilhelmZA WilhelmZA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving at 5de3a704.

Checked the web.locale model, type, fixture, sample and embedded config, the dayjs locale lookup and fallback, the shared formatter in the copy path, and the focusable tooltips. All commits are verified and the CI gate passed.

Two notes, neither blocks the merge:

  • With web.locale set to a language that dayjs has no file for but the browser can format, such as zu, the age is English and the tooltip is in that language. The docs, sample config and CHANGELOG say both are English.
  • zh-Hant without a region loads the Simplified zh file for the age.

@WilhelmZA WilhelmZA added the reviewing Issue is being reviewed by maintainers label Nov 25, 2026
@jsenecal
jsenecal merged commit 71d3ce7 into main Nov 25, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Python backend: API, models, state, execution docs Improve documentation frontend Next.js UI and the runtime UI build reviewing Issue is being reviewed by maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The route table's Age column is always English, and the Age and Weight tooltips can't be reached by keyboard

3 participants