Skip to content

[feat] i18n: InternationalizationProvider, useTranslator, and Pagination migration - #3765

Merged
nynexman4464 merged 3 commits into
mainfrom
nynexman4464/feat/i18n-scaffold
Jul 17, 2026
Merged

nynexman4464 merged 3 commits into
mainfrom
nynexman4464/feat/i18n-scaffold

Conversation

@nynexman4464

Copy link
Copy Markdown
Contributor

Implements the i18n scaffold designed in #3641. Ships the runtime + provider surface and migrates Pagination as the first component consumer to prove the pattern end-to-end. Fully backward compatible — components with no provider ancestor continue to render today's English strings unchanged.

What's in this PR

Runtime + public API (packages/core/src/i18n/)

  • InternationalizationProvider — sets active locale, accepts optional messages (extra locale catalogs) and overrides (sparse per-locale key overrides).
  • useTranslator() — hook returning a stable translator function (key, values?) => string. Bound to the provider context; safe in render, effects, and event handlers.
  • ICU MessageFormat via intl-messageformat@11 — the first production dependency in @astryxdesign/core.
  • BCP 47 regional-locale fallback: pt-BR → pt → en. Silent fallback with a warn-once diagnostic in dev.
  • Missing-key fallback to the shipped en catalog, always.

Catalog format

  • React Intl JSON, namespaced under @astryx.*.
  • Ships packages/core/locales/en.json with 10 Pagination keys as the seed catalog.
  • Dev-only pseudo locale is generated from en.json at build time (build:i18n runs before Babel; vitest regenerates it via globalSetup before every suite). Pseudo output is git-ignored — it's a pure function of en.json, following the FormatJS / Excalidraw / Lokalise convention.

Pagination migration

  • All 10 hardcoded strings replaced with useTranslator() calls: aria labels, previous/next, page indicator button labels with {page, number}, live-region announcements with {current}/{total}, results ICU plural with =0/one/other, the visible count line with {from, number}/{to, number}/{total, number}.
  • Default English matches current wording — no visible change for consumers.
  • Existing content-override props (labelText, previousButtonText, etc.) still work identically. i18n is the mechanism for the defaults; explicit props still win.

Consumer opt-in shape

import {InternationalizationProvider} from '@astryxdesign/core/i18n';
import fr from './locales/fr.json';

<InternationalizationProvider locale="fr" messages={{fr}}>
  <App />
</InternationalizationProvider>

Or with per-locale overrides for one-off wording:

<InternationalizationProvider
  locale="en"
  overrides={{en: {'@astryx.pagination.next': 'Forward'}}}
>
  <App />
</InternationalizationProvider>

No provider → today's English defaults, no behavior change.

Testing

  • 24 new tests — 19 unit tests for resolve (locale chain, ICU formatting, overrides, fallback warnings) + 5 e2e tests that render real <Pagination> under English, pseudo, sparse French, pt-BR → pt → en chain, and de-DE number formatting.
  • 63 existing Pagination tests pass unchanged — proves the migration is behavior-preserving.
  • Full repo: 5,873 tests / 317 files green.
  • Manual verification: pnpm -F @astryxdesign/core build produces a working dist/; UMD bundle unaffected.

Deferred (not in this PR)

  • RSC / SSR runtime. The context-only surface here works in client components. Server-safe usage needs a framework adapter (next-intl pattern) — separate design.
  • Migrating the remaining 45 components with hardcoded strings. Mechanical follow-up work; better as bite-sized PRs so each component's key names get their own review.
  • Bundle splitting. 178 total system strings ≈ 2 KB gzipped per locale — not worth react-server conditional export complexity yet.
  • Crowdin config. Tooling/process choice, not code — RFC recommends type: react_intl.

Notes for reviewers

  • ESLint allowlist update: InternationalizationProviderProps added to COMPONENT_RULE_ALLOWED in internal/eslint-plugin-astryx/shared.js, matching the existing pattern for LinkProviderProps / LayerProviderProps / MediaThemeProps (provider components render no DOM element).
  • Pseudo locale generator: packages/core/scripts/build-pseudo-locale.mjs. Preserves {ICU placeholders} verbatim, wraps output in ⟦...⟧, accentifies ASCII letters.
  • sync-exports.js picked up the new ./i18n subpath automatically — no manual entry needed.

Refs #3641

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 10, 2026
@vercel

vercel Bot commented Jul 10, 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 17, 2026 5:57pm

Request Review

@cixzhang cixzhang added area:core needs:code-review High-risk change (new package/component/API) — needs human code review before merge and removed area:core labels Jul 11, 2026
@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 12, 2026
@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/i18n-scaffold branch from 6bb6242 to b5c93ac Compare July 13, 2026 19:01
@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/i18n-scaffold branch from b5c93ac to a79523b Compare July 13, 2026 20:11
nynexman4464 added a commit that referenced this pull request Jul 13, 2026
Migrates all ~50 hardcoded strings in PowerSearch through the i18n
scaffold from #3765:

- UI chrome: Field / Operator / Add filter / Remove filter / Delete /
  Cancel / Group operator / Apply, plus value-editor labels and
  placeholders (Value / Values / Time / Date / Search... / Enter
  number... / etc.)
- 21 built-in operator labels: contains / does not contain /
  starts with / is between / is any of / is none of / etc.
- ICU plurals for result counts and overflow summaries:
  {count, plural, one {result} other {results}},
  {count} items, {count} entities, {count} filters

Astryx default English wording is preserved verbatim — consumers who
never render an InternationalizationProvider see no visible change.

Type change (source-breaking, minor in practice): PowerSearchOperator
is now a discriminated union — {key, value, label} (raw text) OR
{key, value, i18nKey} (catalog lookup). Existing consumers with
label: 'is any of' compile unchanged. New i18nKey variant lets
consumers opt into astryx's translated defaults or their own catalog
entries. A bare {key, value} is now a compile error, closing the
'forgot to set a label' footgun.

Consumer report on 274 fbsource files showed:
- 75% use zero explicit operators (get translations for free)
- 25% pass explicit operators; of those, ~81% of labels are
  astryx-default lookalikes ('is any of', 'contains', ...) that
  can migrate to i18nKey for free translation
- ~19% are genuinely custom labels ('in my rotations', 'has the
  phrase', ...) — those keep working via the label variant.

Refs #3641, builds on #3765
nynexman4464 added a commit that referenced this pull request Jul 13, 2026
Migrates all ~50 hardcoded strings in PowerSearch through the i18n
scaffold from #3765:

- UI chrome: Field / Operator / Add filter / Remove filter / Delete /
  Cancel / Group operator / Apply, plus value-editor labels and
  placeholders (Value / Values / Time / Date / Search... / Enter
  number... / etc.)
- 21 built-in operator labels: contains / does not contain /
  starts with / is between / is any of / is none of / etc.
- ICU plurals for result counts and overflow summaries:
  {count, plural, one {result} other {results}},
  {count} items, {count} entities, {count} filters

Astryx default English wording is preserved verbatim — consumers who
never render an InternationalizationProvider see no visible change.

Type change (source-breaking, minor in practice): PowerSearchOperator
is now a discriminated union — {key, value, label} (raw text) OR
{key, value, i18nKey} (catalog lookup). Existing consumers with
label: 'is any of' compile unchanged. New i18nKey variant lets
consumers opt into astryx's translated defaults or their own catalog
entries. A bare {key, value} is now a compile error, closing the
'forgot to set a label' footgun.

Consumer report on 274 fbsource files showed:
- 75% use zero explicit operators (get translations for free)
- 25% pass explicit operators; of those, ~81% of labels are
  astryx-default lookalikes ('is any of', 'contains', ...) that
  can migrate to i18nKey for free translation
- ~19% are genuinely custom labels ('in my rotations', 'has the
  phrase', ...) — those keep working via the label variant.

Refs #3641, builds on #3765
nynexman4464 added a commit that referenced this pull request Jul 14, 2026
Third wave of the core i18n migration, following the scaffold in #3765
and the PowerSearch migration in #3922. Migrates all remaining ~55
hardcoded user-facing strings across 27 components through
useTranslator().

Components: AlertDialog, AppShell, AvatarGroup, Banner, Calendar,
Carousel, Chat (ChatMessageMetadata + ChatPastedTextToken),
CheckboxList, CommandPalette, DateRangeInput, DateTimeInput, Dialog,
DropdownMenu, Lightbox, Markdown, MobileNav, MultiSelector, Popover,
Selector, SideNav, TabList, Table (BaseTable, filtering, selection,
sortable plugins), Toast (Toast + ToastViewport), Tokenizer, TopNav,
TreeList, Typeahead.

Prop defaults with translated fallbacks use the alias-and-resolve
pattern (`label: labelFromProps` in the destructure, then
`const label = labelFromProps ?? t('@astryx.foo.label')` in the body).

Notes:
- DropdownMenu.button is now truly optional and defaults to
  `t('@astryx.dropdownMenu.label')` for its aria-label.
- ChatMessageMetadata uses `i18nKey` on its STATUS_CONFIG map and
  resolves at render (pattern established by PowerSearch operators).
- Markdown.renderBlock takes `t: TranslatorFn` as a parameter,
  threaded through from the top-level Markdown component.
- TreeList switched from `[aria-label='Toggle children']` querySelector
  to `[data-tree-toggle]` for row activation, since the aria-label is
  now locale-dependent.

58 new catalog entries added to packages/core/locales/en.json, all
camelCase per the convention agreed in #3641.

Zero visible changes for consumers who don't render an
InternationalizationProvider.

Refs #3641, builds on #3765 + #3922
@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/i18n-scaffold branch from a79523b to 4731e75 Compare July 14, 2026 22:42
nynexman4464 added a commit that referenced this pull request Jul 14, 2026
Migrates all ~50 hardcoded strings in PowerSearch through the i18n
scaffold from #3765:

- UI chrome: Field / Operator / Add filter / Remove filter / Delete /
  Cancel / Group operator / Apply, plus value-editor labels and
  placeholders (Value / Values / Time / Date / Search... / Enter
  number... / etc.)
- 21 built-in operator labels: contains / does not contain /
  starts with / is between / is any of / is none of / etc.
- ICU plurals for result counts and overflow summaries:
  {count, plural, one {result} other {results}},
  {count} items, {count} entities, {count} filters

Astryx default English wording is preserved verbatim — consumers who
never render an InternationalizationProvider see no visible change.

Type change (source-breaking, minor in practice): PowerSearchOperator
is now a discriminated union — {key, value, label} (raw text) OR
{key, value, i18nKey} (catalog lookup). Existing consumers with
label: 'is any of' compile unchanged. New i18nKey variant lets
consumers opt into astryx's translated defaults or their own catalog
entries. A bare {key, value} is now a compile error, closing the
'forgot to set a label' footgun.

Consumer report on 274 fbsource files showed:
- 75% use zero explicit operators (get translations for free)
- 25% pass explicit operators; of those, ~81% of labels are
  astryx-default lookalikes ('is any of', 'contains', ...) that
  can migrate to i18nKey for free translation
- ~19% are genuinely custom labels ('in my rotations', 'has the
  phrase', ...) — those keep working via the label variant.

Refs #3641, builds on #3765
nynexman4464 added a commit that referenced this pull request Jul 14, 2026
Third wave of the core i18n migration, following the scaffold in #3765
and the PowerSearch migration in #3922. Migrates all remaining ~55
hardcoded user-facing strings across 27 components through
useTranslator().

Components: AlertDialog, AppShell, AvatarGroup, Banner, Calendar,
Carousel, Chat (ChatMessageMetadata + ChatPastedTextToken),
CheckboxList, CommandPalette, DateRangeInput, DateTimeInput, Dialog,
DropdownMenu, Lightbox, Markdown, MobileNav, MultiSelector, Popover,
Selector, SideNav, TabList, Table (BaseTable, filtering, selection,
sortable plugins), Toast (Toast + ToastViewport), Tokenizer, TopNav,
TreeList, Typeahead.

Prop defaults with translated fallbacks use the alias-and-resolve
pattern (`label: labelFromProps` in the destructure, then
`const label = labelFromProps ?? t('@astryx.foo.label')` in the body).

Notes:
- DropdownMenu.button is now truly optional and defaults to
  `t('@astryx.dropdownMenu.label')` for its aria-label.
- ChatMessageMetadata uses `i18nKey` on its STATUS_CONFIG map and
  resolves at render (pattern established by PowerSearch operators).
- Markdown.renderBlock takes `t: TranslatorFn` as a parameter,
  threaded through from the top-level Markdown component.
- TreeList switched from `[aria-label='Toggle children']` querySelector
  to `[data-tree-toggle]` for row activation, since the aria-label is
  now locale-dependent.

58 new catalog entries added to packages/core/locales/en.json, all
camelCase per the convention agreed in #3641.

Zero visible changes for consumers who don't render an
InternationalizationProvider.

Refs #3641, builds on #3765 + #3922
nynexman4464 added a commit that referenced this pull request Jul 15, 2026
Third wave of the core i18n migration, following the scaffold in #3765
and the PowerSearch migration in #3922. Migrates all remaining ~55
hardcoded user-facing strings across 27 components through
useTranslator().

Components: AlertDialog, AppShell, AvatarGroup, Banner, Calendar,
Carousel, Chat (ChatMessageMetadata + ChatPastedTextToken),
CheckboxList, CommandPalette, DateRangeInput, DateTimeInput, Dialog,
DropdownMenu, Lightbox, Markdown, MobileNav, MultiSelector, Popover,
Selector, SideNav, TabList, Table (BaseTable, filtering, selection,
sortable plugins), Toast (Toast + ToastViewport), Tokenizer, TopNav,
TreeList, Typeahead.

Prop defaults with translated fallbacks use the alias-and-resolve
pattern (`label: labelFromProps` in the destructure, then
`const label = labelFromProps ?? t('@astryx.foo.label')` in the body).

Notes:
- DropdownMenu.button is now truly optional and defaults to
  `t('@astryx.dropdownMenu.label')` for its aria-label.
- ChatMessageMetadata uses `i18nKey` on its STATUS_CONFIG map and
  resolves at render (pattern established by PowerSearch operators).
- Markdown.renderBlock takes `t: TranslatorFn` as a parameter,
  threaded through from the top-level Markdown component.
- TreeList switched from `[aria-label='Toggle children']` querySelector
  to `[data-tree-toggle]` for row activation, since the aria-label is
  now locale-dependent.

58 new catalog entries added to packages/core/locales/en.json, all
camelCase per the convention agreed in #3641.

Zero visible changes for consumers who don't render an
InternationalizationProvider.

Refs #3641, builds on #3765 + #3922
nynexman4464 added a commit that referenced this pull request Jul 15, 2026
…iolations

Adds a new ESLint rule that flags any hardcoded user-facing string
literal on JSX attributes / object props / destructure defaults inside
packages/core/src whose prop name matches user-facing conventions:

  Exact:    label, placeholder, title, tooltip, text, summary, message,
            description, hint
  Suffix:   *Label, *Text, *Placeholder, *Title, *Message, *Tooltip,
            *Hint, *Description, *Summary
  All aria-* attributes (with a small exclude list).

The rule ignores tests, doc files, stories, and non-user-facing string
shapes (single lowercase word, SCREAMING_SNAKE, URLs, paths).

Configuration follows the plugin convention: 'error' in strict,
'warn' in recommended.

The rule immediately caught 33 hardcoded strings across 22 files that
my hand-inventory missed during PRs #3765/#3922/#3941 — good
validation. All fixed in this PR using the standard alias-and-resolve
pattern for prop defaults, and t() calls for JSX-attr and
config-property cases. 30 new catalog entries added.

Files migrated: Breadcrumbs, Chat (Composer, ComposerDrawer,
ComposerInput, useSpeechRecognition), CommandPalette (root, input,
list), ContextMenu, DateInput, DateRangeInput, DateTimeInput, Link,
MobileNavToggle, MoreMenu, MultiSelector, Outline, PowerSearch (label,
placeholder, popoverSaveButtonLabel), Resizable/ResizeHandle,
Selector, SideNavHeading, Table/plugins/pagination/useTablePagination,
TimeInput, TopNavHeading, Typeahead.

Placeholders that used '...' (three ASCII dots) are now '…' (Unicode
ellipsis) in en.json — a small typography normalization.

Refs #3641, builds on #3941
@imdreamrunner

Copy link
Copy Markdown
Contributor

Just for discussion: I think localization presents a similar RSC-related tradeoff to theming. If we rely on React context to provide localization settings, any component that reads that context and renders localized text would need to be a Client Component.

In this context, there are roughly three categories of components:

  • Client Components
  • Server Components
  • Pure Components that can run in either environment

Making more Astryx components Client Components would not eliminate most of the benefits of RSC. Applications could still use Server Components for data fetching, server-side logic, and composing the overall page.

However, keeping some Astryx components as Pure Components and server-compatible would provide an additional benefit: those components would not need to contribute to the client-side JavaScript bundle.

For theming, we avoid this constraint by relying on CSS variables rather than React context. Do you think it would be worth exploring a similar context-free mechanism for providing localization settings?

cc: @cixzhang

@nynexman4464

Copy link
Copy Markdown
Contributor Author

So originally I had intended to support RSC by having a function with differing implementations on server/client. #3641 talks a bit about this. It still relied on using react context on client, but on server would use AsyncLocalStorage instead. This would (in theory) make the components possible to use on server. The issue I ran into was obviously react context can only be used at render time, but the AI thought it could be used anywhere. The result was we needed to build a hook version anyhow.

In theory we could avoid context by just using something like a singleeton to provide the strings. The problem there is it makes having a language selector difficult - you'd have to "force" a re-render somehow if the language changes (probably by having each component subscribe to the locale setting). It's not impossible, but seemed more complex.

I didn't push much harder on making it RSC compatible because navi claimed we had a lot of state and context which already made many of the components not work with RSC. To be fair I didn't validate these claims. If we feel really strongly on the RSC angle then I will try to pursue it again.

@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/i18n-scaffold branch from 463bc41 to 8741710 Compare July 17, 2026 16:26
nynexman4464 added a commit that referenced this pull request Jul 17, 2026
Migrates all ~50 hardcoded strings in PowerSearch through the i18n
scaffold from #3765:

- UI chrome: Field / Operator / Add filter / Remove filter / Delete /
  Cancel / Group operator / Apply, plus value-editor labels and
  placeholders (Value / Values / Time / Date / Search... / Enter
  number... / etc.)
- 21 built-in operator labels: contains / does not contain /
  starts with / is between / is any of / is none of / etc.
- ICU plurals for result counts and overflow summaries:
  {count, plural, one {result} other {results}},
  {count} items, {count} entities, {count} filters

Astryx default English wording is preserved verbatim — consumers who
never render an InternationalizationProvider see no visible change.

Type change (source-breaking, minor in practice): PowerSearchOperator
is now a discriminated union — {key, value, label} (raw text) OR
{key, value, i18nKey} (catalog lookup). Existing consumers with
label: 'is any of' compile unchanged. New i18nKey variant lets
consumers opt into astryx's translated defaults or their own catalog
entries. A bare {key, value} is now a compile error, closing the
'forgot to set a label' footgun.

Consumer report on 274 fbsource files showed:
- 75% use zero explicit operators (get translations for free)
- 25% pass explicit operators; of those, ~81% of labels are
  astryx-default lookalikes ('is any of', 'contains', ...) that
  can migrate to i18nKey for free translation
- ~19% are genuinely custom labels ('in my rotations', 'has the
  phrase', ...) — those keep working via the label variant.

Refs #3641, builds on #3765
nynexman4464 added a commit that referenced this pull request Jul 17, 2026
Third wave of the core i18n migration, following the scaffold in #3765
and the PowerSearch migration in #3922. Migrates all remaining ~55
hardcoded user-facing strings across 27 components through
useTranslator().

Components: AlertDialog, AppShell, AvatarGroup, Banner, Calendar,
Carousel, Chat (ChatMessageMetadata + ChatPastedTextToken),
CheckboxList, CommandPalette, DateRangeInput, DateTimeInput, Dialog,
DropdownMenu, Lightbox, Markdown, MobileNav, MultiSelector, Popover,
Selector, SideNav, TabList, Table (BaseTable, filtering, selection,
sortable plugins), Toast (Toast + ToastViewport), Tokenizer, TopNav,
TreeList, Typeahead.

Prop defaults with translated fallbacks use the alias-and-resolve
pattern (`label: labelFromProps` in the destructure, then
`const label = labelFromProps ?? t('@astryx.foo.label')` in the body).

Notes:
- DropdownMenu.button is now truly optional and defaults to
  `t('@astryx.dropdownMenu.label')` for its aria-label.
- ChatMessageMetadata uses `i18nKey` on its STATUS_CONFIG map and
  resolves at render (pattern established by PowerSearch operators).
- Markdown.renderBlock takes `t: TranslatorFn` as a parameter,
  threaded through from the top-level Markdown component.
- TreeList switched from `[aria-label='Toggle children']` querySelector
  to `[data-tree-toggle]` for row activation, since the aria-label is
  now locale-dependent.

58 new catalog entries added to packages/core/locales/en.json, all
camelCase per the convention agreed in #3641.

Zero visible changes for consumers who don't render an
InternationalizationProvider.

Refs #3641, builds on #3765 + #3922
@nynexman4464

Copy link
Copy Markdown
Contributor Author

@imdreamrunner I did some testing and came up with some findings in #4030. In short I think there's only a few components that are "pure" that would benefit from translation. In that case we could implement the translation function that works server or client side. Most of the ones that benefit though already have click handlers, state etc won't be able to be "pure" in the first place. Might still be worth doing if we move to more "pure" components though.

Node's exports field supports subpath wildcards (one `*` in both key and
value), which packages use to publish a directory of assets (e.g. locale
JSON, per-icon SVGs). The previous check called existsSync on the literal
string containing the `*`, which always failed.

Extend the checker to expand the pattern: list the value's directory,
require at least one file to match prefix+suffix. Matches that resolve
outside pkgDir via `..` are rejected — package.json cannot reach beyond
its own root.

Only single-`*` patterns are honored, matching Node's spec. Two or more
stars fall through to the literal existsSync check (which fails, same as
Node's real resolver rejecting them).
Implements the i18n scaffold designed in #3641:

- InternationalizationProvider + useTranslator() hook
- ICU MessageFormat via intl-messageformat@11
- BCP 47 regional-locale fallback (pt-BR -> pt -> en)
- Shipped en.json catalog with 10 Pagination keys
- Dev-only pseudo locale generated at build time

Pagination is migrated as the first component consumer. All 63
existing Pagination tests pass unchanged; 24 new i18n tests added.
Backward compatible: no provider needed, English defaults preserved.

Refs #3641
… API

Address review feedback:

- Rename translator var 'translate' -> 't' inside Pagination (matches RFC).
- Merge @astryx.pagination.pageOfTotalAnnounce into pageOfTotal — the two
  keys had identical content; if they diverge later we split then.
- Silent fallback to en for missing translations in a non-en locale
  (matches i18next / FormatJS default). Reserve console.warn for the
  actual-bug case: a key missing even from the shipped en catalog.
- Canonicalize input to resolveLocaleChain via Intl.Locale.baseName so
  'en-us' / 'PT-br' produce the spec-canonical chain.
- Simplify LookupResult -> string | null now that usedFallback is unused.
@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/i18n-scaffold branch from 8741710 to 43ebff5 Compare July 17, 2026 17:54
nynexman4464 added a commit that referenced this pull request Jul 17, 2026
Migrates all ~50 hardcoded strings in PowerSearch through the i18n
scaffold from #3765:

- UI chrome: Field / Operator / Add filter / Remove filter / Delete /
  Cancel / Group operator / Apply, plus value-editor labels and
  placeholders (Value / Values / Time / Date / Search... / Enter
  number... / etc.)
- 21 built-in operator labels: contains / does not contain /
  starts with / is between / is any of / is none of / etc.
- ICU plurals for result counts and overflow summaries:
  {count, plural, one {result} other {results}},
  {count} items, {count} entities, {count} filters

Astryx default English wording is preserved verbatim — consumers who
never render an InternationalizationProvider see no visible change.

Type change (source-breaking, minor in practice): PowerSearchOperator
is now a discriminated union — {key, value, label} (raw text) OR
{key, value, i18nKey} (catalog lookup). Existing consumers with
label: 'is any of' compile unchanged. New i18nKey variant lets
consumers opt into astryx's translated defaults or their own catalog
entries. A bare {key, value} is now a compile error, closing the
'forgot to set a label' footgun.

Consumer report on 274 fbsource files showed:
- 75% use zero explicit operators (get translations for free)
- 25% pass explicit operators; of those, ~81% of labels are
  astryx-default lookalikes ('is any of', 'contains', ...) that
  can migrate to i18nKey for free translation
- ~19% are genuinely custom labels ('in my rotations', 'has the
  phrase', ...) — those keep working via the label variant.

Refs #3641, builds on #3765
nynexman4464 added a commit that referenced this pull request Jul 17, 2026
Third wave of the core i18n migration, following the scaffold in #3765
and the PowerSearch migration in #3922. Migrates all remaining ~55
hardcoded user-facing strings across 27 components through
useTranslator().

Components: AlertDialog, AppShell, AvatarGroup, Banner, Calendar,
Carousel, Chat (ChatMessageMetadata + ChatPastedTextToken),
CheckboxList, CommandPalette, DateRangeInput, DateTimeInput, Dialog,
DropdownMenu, Lightbox, Markdown, MobileNav, MultiSelector, Popover,
Selector, SideNav, TabList, Table (BaseTable, filtering, selection,
sortable plugins), Toast (Toast + ToastViewport), Tokenizer, TopNav,
TreeList, Typeahead.

Prop defaults with translated fallbacks use the alias-and-resolve
pattern (`label: labelFromProps` in the destructure, then
`const label = labelFromProps ?? t('@astryx.foo.label')` in the body).

Notes:
- DropdownMenu.button is now truly optional and defaults to
  `t('@astryx.dropdownMenu.label')` for its aria-label.
- ChatMessageMetadata uses `i18nKey` on its STATUS_CONFIG map and
  resolves at render (pattern established by PowerSearch operators).
- Markdown.renderBlock takes `t: TranslatorFn` as a parameter,
  threaded through from the top-level Markdown component.
- TreeList switched from `[aria-label='Toggle children']` querySelector
  to `[data-tree-toggle]` for row activation, since the aria-label is
  now locale-dependent.

58 new catalog entries added to packages/core/locales/en.json, all
camelCase per the convention agreed in #3641.

Zero visible changes for consumers who don't render an
InternationalizationProvider.

Refs #3641, builds on #3765 + #3922
github-actions Bot added a commit that referenced this pull request Jul 17, 2026
@nynexman4464
nynexman4464 merged commit acd4fe3 into main Jul 17, 2026
19 checks passed
@nynexman4464
nynexman4464 deleted the nynexman4464/feat/i18n-scaffold branch July 17, 2026 18:02
@nynexman4464
nynexman4464 restored the nynexman4464/feat/i18n-scaffold branch July 17, 2026 19:18
nynexman4464 added a commit that referenced this pull request Jul 17, 2026
Migrates all ~50 hardcoded strings in PowerSearch through the i18n
scaffold from #3765:

- UI chrome: Field / Operator / Add filter / Remove filter / Delete /
  Cancel / Group operator / Apply, plus value-editor labels and
  placeholders (Value / Values / Time / Date / Search... / Enter
  number... / etc.)
- 21 built-in operator labels: contains / does not contain /
  starts with / is between / is any of / is none of / etc.
- ICU plurals for result counts and overflow summaries:
  {count, plural, one {result} other {results}},
  {count} items, {count} entities, {count} filters

Astryx default English wording is preserved verbatim — consumers who
never render an InternationalizationProvider see no visible change.

Type change (source-breaking, minor in practice): PowerSearchOperator
is now a discriminated union — {key, value, label} (raw text) OR
{key, value, i18nKey} (catalog lookup). Existing consumers with
label: 'is any of' compile unchanged. New i18nKey variant lets
consumers opt into astryx's translated defaults or their own catalog
entries. A bare {key, value} is now a compile error, closing the
'forgot to set a label' footgun.

Consumer report on 274 fbsource files showed:
- 75% use zero explicit operators (get translations for free)
- 25% pass explicit operators; of those, ~81% of labels are
  astryx-default lookalikes ('is any of', 'contains', ...) that
  can migrate to i18nKey for free translation
- ~19% are genuinely custom labels ('in my rotations', 'has the
  phrase', ...) — those keep working via the label variant.

Refs #3641, builds on #3765
nynexman4464 added a commit that referenced this pull request Jul 17, 2026
Migrates all ~50 hardcoded strings in PowerSearch through the i18n
scaffold from #3765:

- UI chrome: Field / Operator / Add filter / Remove filter / Delete /
  Cancel / Group operator / Apply, plus value-editor labels and
  placeholders (Value / Values / Time / Date / Search... / Enter
  number... / etc.)
- 21 built-in operator labels: contains / does not contain /
  starts with / is between / is any of / is none of / etc.
- ICU plurals for result counts and overflow summaries:
  {count, plural, one {result} other {results}},
  {count} items, {count} entities, {count} filters

Astryx default English wording is preserved verbatim — consumers who
never render an InternationalizationProvider see no visible change.

Type change (source-breaking, minor in practice): PowerSearchOperator
is now a discriminated union — {key, value, label} (raw text) OR
{key, value, i18nKey} (catalog lookup). Existing consumers with
label: 'is any of' compile unchanged. New i18nKey variant lets
consumers opt into astryx's translated defaults or their own catalog
entries. A bare {key, value} is now a compile error, closing the
'forgot to set a label' footgun.

Consumer report on 274 fbsource files showed:
- 75% use zero explicit operators (get translations for free)
- 25% pass explicit operators; of those, ~81% of labels are
  astryx-default lookalikes ('is any of', 'contains', ...) that
  can migrate to i18nKey for free translation
- ~19% are genuinely custom labels ('in my rotations', 'has the
  phrase', ...) — those keep working via the label variant.

Refs #3641, builds on #3765
nynexman4464 added a commit that referenced this pull request Jul 17, 2026
Third wave of the core i18n migration, following the scaffold in #3765
and the PowerSearch migration in #3922. Migrates all remaining ~55
hardcoded user-facing strings across 27 components through
useTranslator().

Components: AlertDialog, AppShell, AvatarGroup, Banner, Calendar,
Carousel, Chat (ChatMessageMetadata + ChatPastedTextToken),
CheckboxList, CommandPalette, DateRangeInput, DateTimeInput, Dialog,
DropdownMenu, Lightbox, Markdown, MobileNav, MultiSelector, Popover,
Selector, SideNav, TabList, Table (BaseTable, filtering, selection,
sortable plugins), Toast (Toast + ToastViewport), Tokenizer, TopNav,
TreeList, Typeahead.

Prop defaults with translated fallbacks use the alias-and-resolve
pattern (`label: labelFromProps` in the destructure, then
`const label = labelFromProps ?? t('@astryx.foo.label')` in the body).

Notes:
- DropdownMenu.button is now truly optional and defaults to
  `t('@astryx.dropdownMenu.label')` for its aria-label.
- ChatMessageMetadata uses `i18nKey` on its STATUS_CONFIG map and
  resolves at render (pattern established by PowerSearch operators).
- Markdown.renderBlock takes `t: TranslatorFn` as a parameter,
  threaded through from the top-level Markdown component.
- TreeList switched from `[aria-label='Toggle children']` querySelector
  to `[data-tree-toggle]` for row activation, since the aria-label is
  now locale-dependent.

58 new catalog entries added to packages/core/locales/en.json, all
camelCase per the convention agreed in #3641.

Zero visible changes for consumers who don't render an
InternationalizationProvider.

Refs #3641, builds on #3765 + #3922
nynexman4464 added a commit that referenced this pull request Jul 17, 2026
Third wave of the core i18n migration, following the scaffold in #3765
and the PowerSearch migration in #3922. Migrates all remaining ~55
hardcoded user-facing strings across 27 components through
useTranslator().

Components: AlertDialog, AppShell, AvatarGroup, Banner, Calendar,
Carousel, Chat (ChatMessageMetadata + ChatPastedTextToken),
CheckboxList, CommandPalette, DateRangeInput, DateTimeInput, Dialog,
DropdownMenu, Lightbox, Markdown, MobileNav, MultiSelector, Popover,
Selector, SideNav, TabList, Table (BaseTable, filtering, selection,
sortable plugins), Toast (Toast + ToastViewport), Tokenizer, TopNav,
TreeList, Typeahead.

Prop defaults with translated fallbacks use the alias-and-resolve
pattern (`label: labelFromProps` in the destructure, then
`const label = labelFromProps ?? t('@astryx.foo.label')` in the body).

Notes:
- DropdownMenu.button is now truly optional and defaults to
  `t('@astryx.dropdownMenu.label')` for its aria-label.
- ChatMessageMetadata uses `i18nKey` on its STATUS_CONFIG map and
  resolves at render (pattern established by PowerSearch operators).
- Markdown.renderBlock takes `t: TranslatorFn` as a parameter,
  threaded through from the top-level Markdown component.
- TreeList switched from `[aria-label='Toggle children']` querySelector
  to `[data-tree-toggle]` for row activation, since the aria-label is
  now locale-dependent.

58 new catalog entries added to packages/core/locales/en.json, all
camelCase per the convention agreed in #3641.

Zero visible changes for consumers who don't render an
InternationalizationProvider.

Refs #3641, builds on #3765 + #3922
nynexman4464 added a commit that referenced this pull request Jul 17, 2026
Third wave of the core i18n migration, following the scaffold in #3765
and the PowerSearch migration in #3922. Migrates all remaining ~55
hardcoded user-facing strings across 27 components through
useTranslator().

Components: AlertDialog, AppShell, AvatarGroup, Banner, Calendar,
Carousel, Chat (ChatMessageMetadata + ChatPastedTextToken),
CheckboxList, CommandPalette, DateRangeInput, DateTimeInput, Dialog,
DropdownMenu, Lightbox, Markdown, MobileNav, MultiSelector, Popover,
Selector, SideNav, TabList, Table (BaseTable, filtering, selection,
sortable plugins), Toast (Toast + ToastViewport), Tokenizer, TopNav,
TreeList, Typeahead.

Prop defaults with translated fallbacks use the alias-and-resolve
pattern (`label: labelFromProps` in the destructure, then
`const label = labelFromProps ?? t('@astryx.foo.label')` in the body).

Notes:
- DropdownMenu.button is now truly optional and defaults to
  `t('@astryx.dropdownMenu.label')` for its aria-label.
- ChatMessageMetadata uses `i18nKey` on its STATUS_CONFIG map and
  resolves at render (pattern established by PowerSearch operators).
- Markdown.renderBlock takes `t: TranslatorFn` as a parameter,
  threaded through from the top-level Markdown component.
- TreeList switched from `[aria-label='Toggle children']` querySelector
  to `[data-tree-toggle]` for row activation, since the aria-label is
  now locale-dependent.

58 new catalog entries added to packages/core/locales/en.json, all
camelCase per the convention agreed in #3641.

Zero visible changes for consumers who don't render an
InternationalizationProvider.

Refs #3641, builds on #3765 + #3922
@github-actions
github-actions Bot deleted the nynexman4464/feat/i18n-scaffold branch July 18, 2026 06:42

This branch was successfully deployed

1 active deployment
Preview — 43ebff58 Deployed Jul 17, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants