feat(react): add context derivation#1173
Merged
ErnestM1234 merged 12 commits intomainfrom Apr 7, 2026
Merged
Conversation
Contributor
Author
|
@greptileai plz re-review |
Contributor
Author
|
@greptileai plz review |
Contributor
Author
|
@greptileai plz review |
Contributor
Author
|
@greptileai plz-review |
Contributor
Author
|
@greptileai plz-review |
Contributor
|
@greptile-ai please re-review |
archie-mckenzie
approved these changes
Apr 7, 2026
Merged
ErnestM1234
pushed a commit
that referenced
this pull request
Apr 7, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## gt-i18n@0.8.0 ### Minor Changes - [#1173](#1173) [`6b0b56b`](6b0b56b) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - add context derivation ## gt-next@6.16.0 ### Minor Changes - [#1173](#1173) [`6b0b56b`](6b0b56b) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - add context derivation ### Patch Changes - Updated dependencies \[[`6b0b56b`](6b0b56b)]: - gt-i18n@0.8.0 - gt-react@10.18.0 - @generaltranslation/compiler@1.3.1 ## gt-node@0.5.0 ### Minor Changes - [#1173](#1173) [`6b0b56b`](6b0b56b) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - add context derivation ### Patch Changes - Updated dependencies \[[`6b0b56b`](6b0b56b)]: - gt-i18n@0.8.0 ## gt-react@10.18.0 ### Minor Changes - [#1173](#1173) [`6b0b56b`](6b0b56b) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - add context derivation ### Patch Changes - Updated dependencies \[[`6b0b56b`](6b0b56b)]: - gt-i18n@0.8.0 - @generaltranslation/react-core@1.8.0 ## @generaltranslation/react-core@1.8.0 ### Minor Changes - [#1173](#1173) [`6b0b56b`](6b0b56b) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - add context derivation ### Patch Changes - Updated dependencies \[[`6b0b56b`](6b0b56b)]: - gt-i18n@0.8.0 ## gt-tanstack-start@0.4.0 ### Minor Changes - [#1173](#1173) [`6b0b56b`](6b0b56b) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - add context derivation ### Patch Changes - Updated dependencies \[[`6b0b56b`](6b0b56b)]: - gt-i18n@0.8.0 - gt-react@10.18.0 - @generaltranslation/react-core@1.8.0 ## gt@2.14.6 ### Patch Changes - [#1173](#1173) [`6b0b56b`](6b0b56b) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - add context derivation - Updated dependencies \[[`6b0b56b`](6b0b56b)]: - @generaltranslation/python-extractor@0.2.7 ## @generaltranslation/compiler@1.3.1 ### Patch Changes - [#1173](#1173) [`6b0b56b`](6b0b56b) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - add context derivation ## gtx-cli@2.14.6 ### Patch Changes - Updated dependencies \[[`6b0b56b`](6b0b56b)]: - gt@2.14.6 ## locadex@1.0.141 ### Patch Changes - Updated dependencies \[[`6b0b56b`](6b0b56b)]: - gt@2.14.6 ## @generaltranslation/gt-next-lint@14.0.0 ### Patch Changes - Updated dependencies \[[`6b0b56b`](6b0b56b)]: - gt-next@6.16.0 ## @generaltranslation/python-extractor@0.2.7 ### Patch Changes - [#1173](#1173) [`6b0b56b`](6b0b56b) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - add context derivation Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
moss-bryophyta
added a commit
to generaltranslation/content
that referenced
this pull request
Apr 7, 2026
…ons + devlog - Add context derivation section to derive string and component templates - Update T context prop description to mention derive() - Update InlineTranslationOptions $context to mention derive() - Add devlog for gt-next@6.16.0 covering context derivation feature Ref: generaltranslation/gt#1173
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.
add the ability to derive context
Greptile Summary
This PR adds context derivation support across the React/Next.js CLI extractor, the SWC Rust compiler plugin, and the Python extractor. When a translation call uses
derive()in its$contextattribute (e.g.<T context={derive(getFormality())}>…</T>ort("Hello", { $context: derive(getFormality()) })), the toolchain now statically resolves all possible context variants and emits one translation entry per variant, sharing astaticIdto group them together.Confidence Score: 5/5
Safe to merge; all remaining findings are P2 style/defensive improvements that do not affect the happy path.
The feature works correctly for the normal case. Both P2 findings are edge-case defensive improvements (stale metadata key and empty-array guard) that would only manifest in unusual error conditions or with dollar-prefixed $context syntax. No P0/P1 logic errors were found.
parseTProps.ts (stale $context key) and handleLiteralTranslationCall.ts / derivation/index.ts (empty contextVariants truthy check)
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Source: context={derive(fn())} or $context=derive(fn())] --> B{CLI/Babel parse} B --> C[containsDeriveCall detects derive] C --> D[Store _contextDeriveExpr on metadata] D --> E[handleDerivation resolves fn return variants] E --> F{Resolved?} F -- Yes: variants=[formal,casual] --> G[contextVariants array] F -- No --> H[Push error, contextVariants=undefined] G --> I{Content type?} I -- JSX Tree --> J[parseJsx: emit N updates, one per context variant] I -- String Literal --> K[handleLiteralTranslationCall: emit N updates] I -- Derive content --> L[deriveExpression: cross-product content×context] J --> M[Each update: source + context + shared staticId] K --> M L --> M M --> N[Compiler: hash='' when hasDeriveContext, CLI resolves real hashes]Prompt To Fix All With AI
Reviews (5): Last reviewed commit: "fix greptile feedback" | Re-trigger Greptile