Repository navigation
fix(i18n): catch formatter returns and localize helper text - #7849
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
|
There was a problem hiding this comment.
Recommending approval: the pasted-text count, file-size limit and keyboard-shortcut text now come from the catalog with English output unchanged, and the lint extension catches exactly the helper returns this PR fixes. Nothing is required before merge; optionally, the changeset could mention that the visible Ctrl/Esc keycaps are translatable too, and that file-size digits now follow the provider locale (for example 1,5 KB under de) even before translations exist.
[Automated review]
bcc7234 to
bb999f8
Compare
There was a problem hiding this comment.
Requesting changes: the catalog changes for Kbd, the pasted-text count and FileInput keep English output unchanged and look right, but the extended lint rule now fails CI's Lint job on this branch. Its new formatter-return check flags two CSS serializers that landed on main after this branch's original base: format() in packages/core/src/motion/animator.ts (line 551) and formatMotionRoleValue() in packages/core/src/motion/roleValue.ts (line 90). Please have the rule skip CSS value fragments such as px and s (or rename or annotate those two helpers), then rerun the rule-only audit against the current main.
[Automated review]
| } | ||
| // These names describe CSS output, not interface copy. A text-sink suffix | ||
| // still wins: formatColorLabel is not a color serializer. | ||
| return !/(?:CSS|Css|Style|Styles|Color|Shadow|Transform|Gradient|Length|Angle|RGB|Rgb|HSL|Hsl|Hex|Transition|Font|Border|GridTemplate|ClassName|MediaQuery|Selector|Path)(?:String|Value)?$/.test( |
There was a problem hiding this comment.
This exclusion misses the two CSS serializers now on main: format() in packages/core/src/motion/animator.ts (line 551, "px ") and formatMotionRoleValue() in packages/core/src/motion/roleValue.ts (line 90, "s "). CI's Lint job fails with exactly those two errors. Skipping CSS unit fragments such as px, s, ms and deg, or renaming or annotating those two helpers, would clear it.
There was a problem hiding this comment.
Recommending approval: the pasted-text count, file-size limit and keyboard-shortcut text now come from the catalog with English output unchanged, and the extended lint rule is clean on current main. One optional follow-up: the unit-chunk exemption in no-hardcoded-i18n-string.js also matches a leading space, so a formatter returning ${n} s or ${n} ms (display text, not CSS) slips past the new check, and dropping the leading \s* keeps both motion serializers exempt. The changeset could also mention that the visible Ctrl/Esc keycaps become translatable and that file-size digits follow the provider locale (for example 1,5 KB under German) before any translation exists.
[Automated review]
| const raw = quasi.value?.cooked ?? quasi.value?.raw ?? ''; | ||
| // A unit following an interpolation is CSS, not English prose. Keep | ||
| // this formatter-only and do not exempt chunks like "s remaining". | ||
| if (opts.requireEnglish && index > 0 && /^\s*(?:px|s|ms|deg)\s*$/.test(raw)) { |
There was a problem hiding this comment.
Optional: the leading \s* isn't needed for the two motion serializers (their chunks are px and s ), but it also exempts space-separated units such as ${n} s or ${n} ms returned by a formatter. Those are display text rather than CSS, since CSS never puts a space between a number and its unit. Dropping it keeps both serializers exempt:
if (opts.requireEnglish && index > 0 && /^(?:px|s|ms|deg)\s*$/.test(raw)) {There was a problem hiding this comment.
Incremental review of eaec231..e928b97; prior findings carried: user_impact
Recommending approval: the CSS-unit exemption in no-hardcoded-i18n-string.js now skips only a unit that starts right at an interpolation, so formatters returning display units such as ${n} s or ${n} ms are flagged again while both motion serializers stay exempt, and the changeset now describes the translatable Ctrl/Esc keycaps and the provider-locale file-size digits. The rule stays clean on this branch merged with current main, and nothing else is needed before merge.
[Automated review]
e928b97 to
17f68be
Compare
There was a problem hiding this comment.
Recommending approval: the pasted-text count, file-size limit and keyboard-shortcut text now come from the catalog with English output unchanged, and the extended lint rule catches the helper returns this PR rewrites while staying clean at this head. Nothing is required before merge.
[Automated review]
Main's meta#7849 localized Kbd's key names through useTranslator(), the whole English catalog. Kbd now renders with useComponentTranslator over the kbd namespace it reads, like every core component in this sweep. Red first: check:i18n-catalog (six slice coverage problems in Kbd.tsx before, none now).
User impact
Pasted-text counts, file-size validation limits, and keyboard shortcut names could stay in English under a non-English provider. Their helper returns also bypassed the hardcoded-string lint rule.
Problem and solution fit
The rule checked text props and announcements but not named text-formatting helpers. That let constructed English escape the catalog, preventing applications from localizing system-owned text. Check those helper returns and move the remaining text into the canonical catalog.
Expected behavior and authority
Internationalization INV1a requires catalog-backed system text and ICU messages for runtime-varying text. INV3 and INV4 require deterministic English fallback and live provider updates.
Smallest restoration
format*andget*String/Text/Label/Messagereturns, including arrows, methods, class fields, assignments, and conventional memo/callback wrappers. Walk templates, concatenation, fallbacks, and TypeScript assertions without tracing identifiers or descending into unrelated callbacks.formatColorLabelremain checked..0number skeleton.No public props, styling, layout, interaction, or translation-runtime changes. New keys fall back to English until translated.
Evidence
b0981237→ 0 on this branch.Scope
Testing
node internal/eslint-plugin-astryx/no-hardcoded-i18n-string.test.mjs pnpm exec vitest run --project ui \ packages/core/src/Chat/ChatPastedTextToken.test.tsx \ packages/core/src/FileInput/FileInput.test.tsx \ packages/core/src/FileInput/FileInput.fr10.test.tsx \ packages/core/src/Kbd/Kbd.test.tsx \ packages/core/src/i18n/useTranslator.test.tsx --maxWorkers=4 pnpm check:i18n-catalog pnpm check:i18n-runtime pnpm check:knowledge pnpm check:changesetsFocused ESLint: no errors or i18n findings; the existing unused
BasePropsimport warning in FileInput is unchanged. Full CI and real-browser verification are not claimed by this draft. No pixels, focus, or interaction logic changed.CSS serializer regression follow-up (2026-10-27)
The rebase exposed two formatter-return false positives in motion CSS serializers:
format()returns apxchunk andformatMotionRoleValue()returns anschunk. The rule now skips only px/s/ms/deg-only template chunks after interpolations, and only on formatter returns. Prose such ass remaining,seconds remaining, andin, plain string returns, and announcement checks remain enforced. No motion code changed.b8fd8615and this PR: 736 tracked production files; main 7 findings, PR 0 findings. The original three component findings remain detectable; neither motion serializer is flagged.eaec231e.Review suggestions follow-up
The CSS-unit exemption now requires the unit immediately after an interpolation. Space-separated display text such as
${n} sor${n} msis checked, while both motion serializers remain exempt. The changeset now explicitly covers translated Ctrl/Esc keycaps and provider-locale file-size digits.6b96fc3e: 738 production files, 7 real findings; this PR's 736 production files, 0 findings.e928b97abefore merge.