Repository navigation
[feat] i18n: InternationalizationProvider, useTranslator, and Pagination migration - #3765
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
6bb6242 to
b5c93ac
Compare
b5c93ac to
a79523b
Compare
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
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
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
a79523b to
4731e75
Compare
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
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
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
…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
|
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:
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 |
|
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 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. |
463bc41 to
8741710
Compare
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
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
|
@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.
8741710 to
43ebff5
Compare
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
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
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
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
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
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
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
Implements the i18n scaffold designed in #3641. Ships the runtime + provider surface and migrates
Paginationas 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 optionalmessages(extra locale catalogs) andoverrides(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.intl-messageformat@11— the first production dependency in@astryxdesign/core.pt-BR→pt→en. Silent fallback with a warn-once diagnostic in dev.encatalog, always.Catalog format
@astryx.*.packages/core/locales/en.jsonwith 10 Pagination keys as the seed catalog.en.jsonat build time (build:i18nruns before Babel;vitestregenerates it viaglobalSetupbefore every suite). Pseudo output is git-ignored — it's a pure function ofen.json, following the FormatJS / Excalidraw / Lokalise convention.Pagination migration
useTranslator()calls: aria labels, previous/next, page indicator button labels with{page, number}, live-region announcements with{current}/{total},resultsICU plural with=0/one/other, the visible count line with{from, number}/{to, number}/{total, number}.labelText,previousButtonText, etc.) still work identically. i18n is the mechanism for the defaults; explicit props still win.Consumer opt-in shape
Or with per-locale overrides for one-off wording:
No provider → today's English defaults, no behavior change.
Testing
resolve(locale chain, ICU formatting, overrides, fallback warnings) + 5 e2e tests that render real<Pagination>under English, pseudo, sparse French,pt-BR → pt → enchain, andde-DEnumber formatting.pnpm -F @astryxdesign/core buildproduces a workingdist/; UMD bundle unaffected.Deferred (not in this PR)
next-intlpattern) — separate design.react-serverconditional export complexity yet.type: react_intl.Notes for reviewers
InternationalizationProviderPropsadded toCOMPONENT_RULE_ALLOWEDininternal/eslint-plugin-astryx/shared.js, matching the existing pattern forLinkProviderProps/LayerProviderProps/MediaThemeProps(provider components render no DOM element).packages/core/scripts/build-pseudo-locale.mjs. Preserves{ICU placeholders}verbatim, wraps output in⟦...⟧, accentifies ASCII letters.sync-exports.jspicked up the new./i18nsubpath automatically — no manual entry needed.Refs #3641