Repository navigation
feat(cli): migrate a raw InternationalizationContext value to the provider #7969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
5e4c993
perf(i18n): let a component carry only its own English strings
vjeux dcb9666
chore(i18n): declare the raw-context path's retirement
vjeux 3a4142e
feat(cli): migrate a raw InternationalizationContext value to the pro…
vjeux 0ac8edf
docs(i18n): scope the breaking entry to the hooks this revision moves…
vjeux 7df8e75
fix(cli): the context codemod edits only what it can prove and rewrit…
vjeux e3f5f14
fix(cli): the context codemod resolves block scopes
vjeux 58003b9
fix(cli): the context codemod imports the provider under a free name …
vjeux 17e3421
fix(cli): the context codemod checks the provider name it writes; tri…
vjeux db49087
fix(cli): type the codemod's provider name as a string
vjeux 80d6ebf
fix(cli): the context codemod maps only a variable's required fields;…
vjeux d99cf19
docs(cli): say what the context codemod maps for a variable
vjeux d359e1b
test(cli): the context codemod leaves the consumer shape in the wild …
vjeux 011b8ae
fix(cli): the context codemod's TODO names the local that shadows the…
vjeux 33cfa85
fix(cli): the context codemod leaves an empty literal behind the TODO…
vjeux ed99b8d
fix(cli): the context codemod sees private-method parameters, static …
vjeux fab7ed1
fix(cli): the context codemod sees an exported namespace member as a …
vjeux 627acf0
fix(cli): the context codemod sees import-equals and ambient declarat…
vjeux c44090d
fix(cli): the context codemod counts a nested namespace as a binding
vjeux 25a4e58
fix(cli): the context codemod sees a dotted namespace as binding its …
vjeux 88c4340
docs: importing InternationalizationContext also carries the whole ca…
vjeux b0588ff
fix(cli): the context codemod declines a spread that follows value
vjeux df7c3f5
chore(cli): the context codemod moves to its own stacked pull request
vjeux 8da012c
docs(i18n): the breaking entry carries the migration as the changelog…
vjeux 0de5c8e
fix(build): the Vite locale alias takes one path segment, so a slice …
vjeux f9267e0
test(i18n): resolve the locale exports through the package's self-ref…
vjeux 8500a50
feat(cli): migrate a raw InternationalizationContext value to the pro…
vjeux df5d915
Merge main into perf/i18n-context-codemod
vjeux 5b4e841
fix(codemod): a getter or a method in an inline context value stays b…
vjeux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@astryxdesign/cli': patch | ||
| --- | ||
|
|
||
| [docs] The i18n, RTL and testing guide keeps to what holds for a caller: `useTranslator()` resolves every `@astryx.*` key; how a core component reads its strings moves to the contributing guide. | ||
|
|
||
| @vjeux |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@astryxdesign/cli': patch | ||
| --- | ||
|
|
||
| [feat] `astryx upgrade` runs `migrate-internationalization-context`, which rewrites `<InternationalizationContext value={…}>` (or its `.Provider`) to `<InternationalizationProvider locale dir messages overrides>`: a variable maps `locale`, `direction` (as `dir`) and `messages` — the fields every context value has — and its TODO names `overrides` and `translate`, which the variable's type may lack and the provider has no input for; an inline object literal maps key by key, `overrides` included, with a TODO for `translate` (a literal's `translate` key is kept beside it). Any other value — a call, a spread into a literal, a conditional — is left unchanged behind a TODO saying why. It rewrites JSX whose name resolves, unshadowed, to an Astryx import (named, aliased, or namespace), reuses the file's own provider import name, and leaves a reader of the context alone. | ||
|
|
||
| @vjeux | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@astryxdesign/core': minor | ||
| --- | ||
|
|
||
| [breaking] An app that sets `InternationalizationContext` directly — rendering `<InternationalizationContext value={…}>` (or its `.Provider`) instead of `InternationalizationProvider` — no longer drives `useLocale`, `useDirection` and `useCollator`, nor the components that read the locale or direction through them (the date, date-time, date-range and number inputs, Calendar, Chat, PowerSearch, Table sorting and filtering, Timestamp). Its strings still follow such a value through `useTranslator()`, as does the locale of `DateTimeInput`'s touch field, until the components move to their own slices, which stops that too. Migration: mount `InternationalizationProvider`; its `locale`, `messages` and `overrides` take the value's fields of the same name, and its `dir` takes the value's `direction`. The provider has no `translate` input: an app that supplied its own `translate` expresses those strings as `messages` (a catalog per locale) or `overrides` (sparse, per locale) and the provider resolves them in the documented order. Run `astryx upgrade`: its `migrate-internationalization-context` transform rewrites a variable value to the provider's `locale`, `dir` and `messages` with a TODO for its `overrides` and `translate`, and an inline object literal key by key with a TODO for `translate`; any other value, and any element that spreads props, is left as written behind a TODO saying why. The provider now writes an internal runtime context that those hooks read. Reading the public context is unchanged, so a component that reads it with `useContext` and re-mounts `InternationalizationProvider` with a derived value keeps working: `locale`, `direction`, `messages`, `overrides` and `translate`, which still resolves every `@astryx.*` key against the whole shipped English catalog, with or without a provider; `useTranslator()` is unchanged. Groundwork for components carrying only their own English strings: the English catalog is also emitted one namespace at a time, the resolver takes its English fallback per call, and an internal `useComponentTranslator(slice)` lets a core component render with its own slice. The slices are not importable. | ||
|
|
||
| @vjeux |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@astryxdesign/build': patch | ||
| --- | ||
|
|
||
| [fix] `astryxStylex()`'s alias for `@astryxdesign/core/locales/<locale>.generated.js` takes one path segment, so the per-namespace English slices under `locales/en/` — which the package's exports map keeps out of reach — no longer resolve through the source tree in a Vite app either. | ||
|
|
||
| @vjeux |
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This says
astryx upgraderuns the transform, butpackages/cli/assets/codemods/transforms/next/index.mjsstill exports[]and the codemod registry runs only manifest entries, so at this head the transform never runs. Restoring the manifest entry, dropped when the codemod moved out of #7357, makes this sentence true.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registered in bb41827 — the split had dropped the manifest entry, which is exactly the kind of gap that ships silently.
transforms/next/index.mjsnow exports{name: 'migrate-internationalization-context', transform, meta}, and the fixture file opens with a test that the manifest lists the transform by name with the sametransformandmetaidentities.