Closed nbouvrette closed 4 years ago
Extra info - just tested using ICU4J and it doesn't seem like the closing quote is necessary - not sure where we can confirm this is part of the specifications on the other hand.
thanks a lot for reporting. We're focusing on the intl-unified-numberformat
polyfill so it might take a while to get back to this. PR's definitely always welcome :)
I wish I could do a PR but will barely have time to prepare for the next message format working group demo of my syntax tool - hopefully you can join and give my your thoughts!
Fixed in https://github.com/formatjs/formatjs/pull/380 (to be released)
Which package? https://github.com/formatjs/formatjs/tree/master/packages/intl-messageformat
Describe the bug I'm seeing so odd behaviors using single quote escapes that don't seem to match exactly the behavior I found in the ICU documentation.
To Reproduce Steps to reproduce the behavior:
In Chrome console:
Test 1: opening quotes must include closing quotes
Output (test pass):
You have {count
Test 2: removing the closing quote should return an error
Output (test pass):
Uncaught SyntaxError: Expected "'", "''", ",", or [^'] but end of input found.
Test 3: closing the brace on the argument should not impact the escape behavior
Output (test fail):
You have '1
Expected result: the variable should not be displayed and the parser should return an error since the quote has not been closed.
Test 4: escape should also apply placeholders (#)
Output (test fail):
You worked for '1' hour today.
Expected result: the variable should not be displayed. The parser should also return an error if we try the same string without closing the quote.
Desktop (please complete the following information):
Additional context
Ref: https://unicode-org.github.io/icu-docs/apidoc/released/icu4j/com/ibm/icu/text/MessageFormat.html
messageText can contain quoted literal strings including syntax characters. A quoted literal string begins with an ASCII apostrophe and a syntax character (usually a {curly brace}) and continues until the next single apostrophe. A double ASCII apostrophe inside or outside of a quoted string represents one literal apostrophe.
Quotable syntax characters are the {curly braces} in all messageText parts, plus the '#' sign in a messageText immediately inside a pluralStyle, and the '|' symbol in a messageText immediately inside a choiceStyle.