fix: reassemble comma-in-parens formatters at any chain position#2437
Merged
adrai merged 1 commit intoJun 24, 2026
Merged
Conversation
Chained formatters support parenthesised options that may contain the
format separator (e.g. join(separator: ', ')). The reassembly that
rejoins such split fragments only ran for formats[0], so a formatter
with comma-in-parens options anywhere other than first produced corrupt
output (e.g. {{v, upper, join(separator: ', ')}} yielded 'ANaNB').
Reassemble fragments in a single position-independent pass so options
containing the separator are handled at any position in the chain.
adrai
added a commit
that referenced
this pull request
Jun 24, 2026
Member
|
thx.... merged and included in v26.3.2 |
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.
Problem
Chained formatters support parenthesised options that may contain the format separator, for example
join(separator: ', '). When such a formatter is split on the separator, the option fragments have to be rejoined before parsing.Today that reassembly only runs for
formats[0]. A formatter whose parenthesised options contain the separator therefore works only when it is first in the chain:In the broken case the
join(separator: ', ')fragment is split intojoin(separator: ' 'and')', never rejoined, and the value comes out corrupted (e.g.ANaNB).Fix
Replace the
formats[0]-only repair with a single position-independent pass: walk the split fragments and, whenever a fragment opens a paren that is not yet closed, keep appending following fragments (re-inserting the separator) until the paren closes. This reassembles comma-in-parens options at any position in the chain. The downstreamformats.reduce(...)is unchanged.Tests
Added a regression test in
test/runtime/i18next.translation.formatting.test.jsexercising a chain where the comma-in-parens formatter is not first ({{myVar, upper, join(separator: ', ')}}with['a','b']->A, B).Hello ANaNB).