Skip to content

fix(Table): translate sort header screen-reader labels - #4073

Merged
humbertovirtudes merged 2 commits into
meta:mainfrom
AKnassa:ak-3618-sort-aria-i18n
Jul 22, 2026
Merged

humbertovirtudes merged 2 commits into
meta:mainfrom
AKnassa:ak-3618-sort-aria-i18n

Conversation

@AKnassa

@AKnassa AKnassa commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

What this does

Makes the Table sort headers' screen-reader labels ("Sort by Name, sorted ascending, priority 1 of 2") translatable, like the rest of the component strings.

Why

The i18n system and catalog are live, and the sort context-menu labels were already migrated — but the header button labels come from a plain helper whose return value slips past the hardcoded-string lint rule, so they stayed English in every locale. This closes the last concrete gap raised in #3618, under tracker #3636.

What changed

  • The three label forms now go through the translator with full-sentence messages (word order stays correct in every language; "ascending"/"descending" translate via their own entries, following the Chat precedent). ICU select inside the sentence was considered instead; the separate word key won for consistency with Chat's existing status pattern — one for the [Tracker] i18n & RTL support — string injection + RTL correctness #3636 standardization discussion.
  • 5 new catalog entries; English output is byte-identical, proven by the untouched existing tests.
  • 3 new tests verify a French-style override, the multi-sort priority form, and the direction words. The overridden words deliberately differ from the raw enum values, so raw-enum interpolation or a hardcoded English frame fails the suite (mutation-verified: each doctored implementation fails exactly its test).

How to see it

pnpm exec vitest run packages/core/src/Table/plugins/sortable/useTableSortable.test.tsx — 40/40 pass. Lint passes with no suppressions.

Fixes #3618

buildAriaLabel still hardcoded English ('Sort by X, sorted ascending,
priority 1 of 2') after the i18n sweep migrated the sort menu labels —
the plain-helper return value evades the no-hardcoded-i18n-string lint
rule. Route all three aria-label forms through useTranslator() with
full-sentence ICU messages (no segment concatenation; direction words
resolve via their own keys, following the Chat status precedent).
English output is byte-identical.

Closes the last concrete gap of meta#3618; part of tracker meta#3636.

Claude-Session: https://claude.ai/code/session_01P9qSoGWZPPp9pUNNRUSwkM
@vercel

vercel Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 19, 2026 3:48am

Request Review

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Jul 19, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 19, 2026
@github-actions

github-actions Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.7KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | View full report

- Override both direction keys in the multi-sort test with words that
  differ from the raw enum values, proving descending (and the priority
  branch) resolve through @astryx.table.sort.direction.* rather than
  interpolating the enum.
- Also override @astryx.table.sort.sortedBy in the single-sort test,
  proving the composed template routes through the catalog (a hardcoded
  English frame previously went undetected).
- Move t() into each ternary branch so the direction-key literals are
  visible to the @astryx/i18n-key-format lint rule.

Both gaps mutation-verified: each doctored implementation fails exactly
its new test; the untouched suite stays 40/40.

@humbertovirtudes humbertovirtudes 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.

Approving. Clean closure of the last gap in #3618.

The three header-button label forms now route through useTranslator() with the new catalog keys, and resolving the direction word through its own direction.* entry rather than interpolating the raw enum is the correct call. English output is byte-identical, which the untouched existing tests confirm.

The new tests are mutation-resistant, not tautological: the French overrides (croissant/decroissant) deliberately differ from the raw enum values, so a hardcoded English frame or raw-enum interpolation fails the suite for both directions.

One thing worth a note, not blocking: interpolating a separately-translated word into a sentence carries the usual fragment-composition risk (gender and declension can shift the surrounding words in some languages). You flagged the ICU select alternative and chose the separate-key approach to match the existing Chat status precedent, deferring the standardization to #3636. That is a reasonable, precedent-backed tradeoff.

Thanks for the careful work here. CI is green.

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Jul 22, 2026
@humbertovirtudes
humbertovirtudes merged commit 32893d3 into meta:main Jul 22, 2026
24 checks passed
@github-actions
github-actions Bot deleted the ak-3618-sort-aria-i18n branch July 22, 2026 08:25

This branch was successfully deployed

1 active deployment
Preview — 56aa2f05 Deployed Jul 19, 2026 by vercel[bot]
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. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: i18n/strings provider for component-internal strings (Table sort aria, Pagination, Calendar months)

2 participants