Repository navigation
[feat] i18n: route ternary + templated strings through useTranslator() - #4013
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
nynexman4464
marked this pull request as ready for review
July 15, 2026 22:29
nynexman4464
requested review from
cixzhang,
ejhammond and
imdreamrunner
as code owners
July 15, 2026 22:29
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-lint-rule
branch
from
July 15, 2026 22:51
1503117 to
be1a23b
Compare
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-more-strings
branch
from
July 15, 2026 22:51
ee7dbfe to
bdadf04
Compare
nynexman4464
added a commit
that referenced
this pull request
Jul 15, 2026
…late patterns
Walks into a JSX-expression container (or a destructure default) and
recursively reports string literals nested inside conditional, logical,
and template-literal expressions. Handles the two patterns that a
plain-literal check missed:
aria-label={isOpen ? 'Close X' : 'Open X'} // ConditionalExpression
aria-label={cond && 'Something'} // LogicalExpression
aria-label={fallback ?? 'Default'} // LogicalExpression
aria-label={`Clear ${label}`} // TemplateLiteral
Deliberately does NOT walk into CallExpression (already handled — t()
calls are the correct form), MemberExpression, Identifier, arrow
function bodies, or JSX expressions — those are either fine or too
likely to false-positive.
Same behavior for the destructure-default case:
function Foo({label = cond ? 'A' : 'B'}) { ... }
function Foo({label = `Default ${x}`}) { ... }
Both are now flagged as `hardcodedDefault`.
Real-world integration testing (pseudo-locale swap on a consumer app)
was the forcing function. The pattern is common enough that a 24-file
migration was needed to green up the extension — landed separately in
#4013 which this PR stacks on.
Refs #3641, builds on #4013
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-lint-rule
branch
from
July 17, 2026 16:26
be1a23b to
062f650
Compare
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-more-strings
branch
from
July 17, 2026 16:26
bdadf04 to
995e996
Compare
nynexman4464
added a commit
that referenced
this pull request
Jul 17, 2026
…late patterns
Walks into a JSX-expression container (or a destructure default) and
recursively reports string literals nested inside conditional, logical,
and template-literal expressions. Handles the two patterns that a
plain-literal check missed:
aria-label={isOpen ? 'Close X' : 'Open X'} // ConditionalExpression
aria-label={cond && 'Something'} // LogicalExpression
aria-label={fallback ?? 'Default'} // LogicalExpression
aria-label={`Clear ${label}`} // TemplateLiteral
Deliberately does NOT walk into CallExpression (already handled — t()
calls are the correct form), MemberExpression, Identifier, arrow
function bodies, or JSX expressions — those are either fine or too
likely to false-positive.
Same behavior for the destructure-default case:
function Foo({label = cond ? 'A' : 'B'}) { ... }
function Foo({label = `Default ${x}`}) { ... }
Both are now flagged as `hardcodedDefault`.
Real-world integration testing (pseudo-locale swap on a consumer app)
was the forcing function. The pattern is common enough that a 24-file
migration was needed to green up the extension — landed separately in
#4013 which this PR stacks on.
Refs #3641, builds on #4013
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-lint-rule
branch
from
July 17, 2026 17:54
062f650 to
726cf27
Compare
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-more-strings
branch
from
July 17, 2026 17:54
995e996 to
bdba214
Compare
nynexman4464
added a commit
that referenced
this pull request
Jul 17, 2026
…late patterns
Walks into a JSX-expression container (or a destructure default) and
recursively reports string literals nested inside conditional, logical,
and template-literal expressions. Handles the two patterns that a
plain-literal check missed:
aria-label={isOpen ? 'Close X' : 'Open X'} // ConditionalExpression
aria-label={cond && 'Something'} // LogicalExpression
aria-label={fallback ?? 'Default'} // LogicalExpression
aria-label={`Clear ${label}`} // TemplateLiteral
Deliberately does NOT walk into CallExpression (already handled — t()
calls are the correct form), MemberExpression, Identifier, arrow
function bodies, or JSX expressions — those are either fine or too
likely to false-positive.
Same behavior for the destructure-default case:
function Foo({label = cond ? 'A' : 'B'}) { ... }
function Foo({label = `Default ${x}`}) { ... }
Both are now flagged as `hardcodedDefault`.
Real-world integration testing (pseudo-locale swap on a consumer app)
was the forcing function. The pattern is common enough that a 24-file
migration was needed to green up the extension — landed separately in
#4013 which this PR stacks on.
Refs #3641, builds on #4013
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-lint-rule
branch
from
July 17, 2026 21:12
726cf27 to
3e97482
Compare
Extends the i18n migration series to catch the two patterns that a
plain-literal audit missed:
aria-label={isOpen ? 'Close X' : 'Open X'} (ternary in JSX attr)
aria-label={`Clear ${label}`} (templated string)
Both slipped past the initial migration because the value on the
attribute is a JSX expression container, not a bare string literal.
Real-world integration testing (French / pseudo locale swap on a
consumer app) caught them.
Migrations by component (27 files):
DateInput / DateRangeInput / DateTimeInput
- calendar toggle aria-label (open/close)
- clear button aria-label (`Clear ${label}`)
Banner, SideNavItem, ChatComposerDrawer
- expand/collapse ternaries
ChatSendButton
- send/stop ternary
ChatLayout, ChatLayoutScrollButton, ChatMessage, ChatTriggerMenu
- templated aria-labels
Citation, CodeBlock, Lightbox, MobileNav
- templated / static aria-labels
MultiSelector, NumberInput, Selector, TextInput, TimeInput, FileInput
- `Clear ${label}` aria-labels
SideNavCollapseButton
- expand/collapse sidebar ternary
Table plugins:
- useTableFiltering — 14 `Filter ${header}` sites consolidated
behind one shared key with ICU {header} variable
- useTableGroupedRows — expand/collapse group templates
- useTableRowExpansion — row-toggle and all-rows-toggle ternaries
Thumbnail, Token
- remove/open templates
33 new catalog entries in packages/core/locales/en.json, all
@AstryX.<component>.* camelCase. All interpolations expressed as ICU
MessageFormat variables. Zero user-visible English changes —
defaultMessage always matches the pre-migration string exactly.
5 sub-components in useTableFiltering that lacked `useTranslator`
now have it. useTriggerMenu / useTableGroupedRows /
useTableRowExpansion needed `t` added to a few exhaustive-deps
arrays (no-op at runtime since useTranslator returns a stable
reference).
Refs #3641, builds on #4010
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-more-strings
branch
from
July 17, 2026 21:28
bdba214 to
5fd23ed
Compare
nynexman4464
changed the base branch from
nynexman4464/feat/i18n-lint-rule
to
main
July 17, 2026 21:28
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
nynexman4464
added a commit
that referenced
this pull request
Jul 17, 2026
…late patterns
Walks into a JSX-expression container (or a destructure default) and
recursively reports string literals nested inside conditional, logical,
and template-literal expressions. Handles the two patterns that a
plain-literal check missed:
aria-label={isOpen ? 'Close X' : 'Open X'} // ConditionalExpression
aria-label={cond && 'Something'} // LogicalExpression
aria-label={fallback ?? 'Default'} // LogicalExpression
aria-label={`Clear ${label}`} // TemplateLiteral
Deliberately does NOT walk into CallExpression (already handled — t()
calls are the correct form), MemberExpression, Identifier, arrow
function bodies, or JSX expressions — those are either fine or too
likely to false-positive.
Same behavior for the destructure-default case:
function Foo({label = cond ? 'A' : 'B'}) { ... }
function Foo({label = `Default ${x}`}) { ... }
Both are now flagged as `hardcodedDefault`.
Real-world integration testing (pseudo-locale swap on a consumer app)
was the forcing function. The pattern is common enough that a 24-file
migration was needed to green up the extension — landed separately in
#4013 which this PR stacks on.
Refs #3641, builds on #4013
nynexman4464
added a commit
that referenced
this pull request
Jul 17, 2026
…late patterns (#4014) Walks into a JSX-expression container (or a destructure default) and recursively reports string literals nested inside conditional, logical, and template-literal expressions. Handles the two patterns that a plain-literal check missed: aria-label={isOpen ? 'Close X' : 'Open X'} // ConditionalExpression aria-label={cond && 'Something'} // LogicalExpression aria-label={fallback ?? 'Default'} // LogicalExpression aria-label={`Clear ${label}`} // TemplateLiteral Deliberately does NOT walk into CallExpression (already handled — t() calls are the correct form), MemberExpression, Identifier, arrow function bodies, or JSX expressions — those are either fine or too likely to false-positive. Same behavior for the destructure-default case: function Foo({label = cond ? 'A' : 'B'}) { ... } function Foo({label = `Default ${x}`}) { ... } Both are now flagged as `hardcodedDefault`. Real-world integration testing (pseudo-locale swap on a consumer app) was the forcing function. The pattern is common enough that a 24-file migration was needed to green up the extension — landed separately in #4013 which this PR stacks on. Refs #3641, builds on #4013
31 of 40 tasks
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #4010. Extends the i18n migration series to catch string literals inside ternary and template-literal expressions on JSX attributes — patterns a plain-literal audit missed:
Both slipped past the initial migration because the attribute value is a
JSXExpressionContainer, not a bareLiteral. Real-world integration testing (pseudo-locale + French locale swap on a consumer app) surfaced ~50 pre-existing hardcoded strings across 24 files.Catalog
33 new entries in
packages/core/locales/en.json, all@astryx.<component>.*camelCase. All interpolations expressed as ICU MessageFormat variables ({label},{header},{sender},{title}, …). Notable consolidation:useTableFilteringhad 14 sites of`Filter ${header}`all sharing one key with an ICU variable.Zero user-visible English changes — every
defaultMessagematches the pre-migration string exactly.Testing
pnpm -F @astryxdesign/core lint: cleanpnpm -F @astryxdesign/core typecheck: cleanRefs #3641, builds on #4010. Follow-up PR extends the
no-hardcoded-i18n-stringrule so this class of miss can't happen again.