Repository navigation
fix(extract): match whole count / context option names in nested $t() - #332
Merged
Merged
Conversation
parseNestedReferences looked for count and context anywhere in the
options string, so $t(price, {"discount": 5}) was treated as a plural
reference and $t(name, {"subcontext": "formal"}) as a context one.
Extraction emitted price_one/price_other instead of price, and with
removeUnusedKeys an existing price translation was dropped.
adrai
added a commit
that referenced
this pull request
Nov 19, 2026
…ole name Like the nested $t() parser in #332: { discount: 5 } made plural keys, { subcontext: 'vip' } a context key and { dns: 'other' } a namespace. A quoted name ({ "count": 2 }) was not read at all.
Member
|
Thanks for this, nice catch and a clean fix. I could reproduce it on main: with removeUnusedKeys an existing The comment parser had the same pattern ( |
zzoraemon043
added a commit
to zzoraemon043/zzoraemon043
that referenced
this pull request
Nov 19, 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.
parseNestedReferenceslooks forcountandcontextanywhere in the options string, so option names that only contain them are picked up too:$t(price, {"discount": {{d}} })is treated as a plural reference.extractwritesprice_one/price_otherinstead ofprice, and withremoveUnusedKeysan existingpricetranslation that is only referenced from another value is replaced by empty plural keys.$t(name, {"subcontext": "formal"})is treated as contextformal.The two regexes now only match a whole property name (at the start, or after
{,,or whitespace, optionally quoted)."count",countand'count'still match as before.Tests: one case in
extractor.nested-translations.test.ts(source code) and one inextractor.nested-translations-in-value.test.ts(removeUnusedKeys). Both fail before the change.npm test(lint + 1629 tests) andtsc --noEmitpass.