Repository navigation
fix(extract): quote adjacent literal braces as one ICU quoted text - #340
Merged
Merged
Conversation
Quoting each brace on its own turned {} into '{''}', which ICU reads as {'}
since '' inside quoted text is an apostrophe. An apostrophe right after a
quoted brace also kept the quote open over a following placeholder.
adrai
added a commit
that referenced
this pull request
Nov 27, 2026
Member
|
Thanks a lot for this one, and for the parser round-trip check. I could reproduce it with a One note for next time: we now ask for an issue first, and once a maintainer has confirmed it, a PR is very welcome. |
Contributor
Author
|
Thanks. Will open an issue first next time. |
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.
With
extract.messageFormat: 'icu',toMessageFormatPlaceholdersquotes each literal brace on its own. Two braces next to each other come out as'{''}', and ICU reads the''between them as an apostrophe inside one quoted text:Use {} for an empty objectUse '{''}' for an empty objectUse {'} for an empty objecta}{ba'}''{'ba}'{b{'}'{''''}'{''}{'x {{name}}'{''x {name}{'x {name}(the placeholder is text)The last one is an apostrophe right after a quoted brace: it is not doubled, so the quote stays open over the placeholder.
The fix quotes a run of braces together with the apostrophes next to it as one quoted text, with the apostrophes doubled inside. Other apostrophes are doubled as before.
Checked by parsing the output with
@formatjs/icu-messageformat-parserfor 30,000 random strings ofa, space,',{,},<,>,<1>,</1>and placeholders: about 10% did not read back as the original text before, none after. Outputs that already read back correctly stay the same, apart from a closing quote now written after a trailing apostrophe ('}'''instead of'}'', same text).The new test fails on main and passes with the fix;
npm test(lint and 1713 tests) andtsc --noEmitpass.