Repository navigation
fix: transform a useLingui t nested in a placeholder of another t - #285
Merged
andrii-bodnar merged 1 commit intoOct 15, 2026
Merged
Conversation
JsMacroFolder returned the i18n call built for `t`, `t({...})` and
plural/select without folding it, so a nested `t` from useLingui()
copied into the values was left as a tagged template on the runtime
function, which returns "". Fold the produced call's children, like
LinguiMacroFolder does and as #279 did for JSX.
Fixes #284
Codecov Reportâ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #285 +/- ##
=======================================
Coverage 94.42% 94.42%
=======================================
Files 11 11
Lines 2529 2530 +1
=======================================
+ Hits 2388 2389 +1
Misses 141 141
Flags with carried forward coverage won't be shown. Click here to find out more.
ð New features to boost your workflow:
|
There was a problem hiding this comment.
ðĒ Approval recommended
The localized fix preserves message construction, covers the reported regressions, and has no identified blocking issues.
0 open findings
What changed in this PR
Fixes #284 by transforming nested useLingui().t calls inside message placeholders, extending the existing nested-macro handling.
Changes:
- Folds generated call children without reprocessing the call itself.
- Adds three regression tests and snapshots covering template, plural-adjacent, and descriptor placeholders.
| File | Description |
|---|---|
crates/âlingui_macro/âtests/âuse_lingui.rs |
Adds three nesting regression tests. |
crates/âlingui_macro/âtests/âsnapshots/âuse_lingui__js_use_lingui_nested_t_next_to_plural_placeholder.snap |
Verifies nesting alongside a plural placeholder. |
crates/âlingui_macro/âtests/âsnapshots/âuse_lingui__js_use_lingui_nested_t_in_placeholder.snap |
Verifies nesting in a template placeholder. |
crates/âlingui_macro/âtests/âsnapshots/âuse_lingui__js_use_lingui_nested_t_in_descriptor_placeholder.snap |
Verifies nesting in a descriptor placeholder. |
crates/âlingui_macro/âsrc/âjs_macro_folder.rs |
Folds generated call children to transform nested macros. |
ð§ Review effort: Balanced
ðĄ Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
timofei-iatsenko
approved these changes
Oct 15, 2026
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.
JsMacroFolderbuilt the i18n call fort`...`,t({...})andplural/select, then returned it without folding it. Placeholder expressions are copied verbatim intovalues, so atfromuseLingui()nested in a placeholder was left as a tagged template on the runtime function, and at runtimei18n._()got aTemplateStringsArrayand returned"". The produced call's children are now folded too, asLinguiMacroFolderdoes for the core macros and as #279 did for JSX. Only the call's arguments are folded (CallExpr::fold_children_with), so the produced call doesn't go throughfold_call_expra second time.Tests (
use_lingui.rs), each producing the output the issue expects:t`Calibrated for ${device || t`Microphone`}`â0: device || $__({ id: "1iY5xv", message: "Microphone" }).tnext to apluralplaceholder.tinside the placeholder oft({ message:...}).All three fail without the change, and
cargo test -p lingui_macro,cargo fmt --checkandcargo clippy -p lingui_macro --all-targets -- -D warningspass. I couldn't run the extractor and native-tools crates locally, becausenapi-builddoesn't build on my Windows GNU toolchain. CI covers those.Fixes #284