I18n questions · ICU message format
Wrap a literal brace in ASCII apostrophes, '{' and '}', and write a literal apostrophe as two apostrophes, ''. In ICU's default apostrophe mode a single apostrophe only starts quoting when it immediately precedes a syntax character, so a plain don't in the text is printed as is.
The ASCII apostrophe (U+0027) is the quoting character of the syntax. Everything between it and the next apostrophe is copied literally, which is how you print braces without starting an argument:
With name set to Ann this prints Use {name} as the placeholder, not Ann. Two adjacent apostrophes always produce one apostrophe, inside or outside quoted text:
Output: This {isn't} a placeholder.
Which apostrophes start quoting depends on the implementation:
android.icu.text.MessageFormat, PHP's MessageFormatter and FormatJS use ICU's "double optional" mode, the default since ICU 4.8. An apostrophe starts quoted text only when it immediately precedes { or }, a # inside a plural branch, or a | inside the old choice format. Every other apostrophe is literal, so It's {count} items prints It's 3 items. FormatJS additionally lets an apostrophe quote < and > because of its rich-text tags.java.text.MessageFormat treats every single apostrophe as the start of quoted text, the mode ICU calls "double required". There you must write It''s {0} items; the pattern It's {0} items quotes everything after the apostrophe and prints Its {0} items.For user-facing text the safest choice is the typographic apostrophe ’ (U+2019). It is never a quoting character in any implementation, it is the correct glyph in English prose, and both the ICU user guide and FormatJS recommend it for human-readable strings, leaving U+0027 to the syntax.
Pitfalls:
'{ silently turns every later placeholder into literal text.'' is portable, since both modes turn a pair into one apostrophe. A single apostrophe not followed by a syntax character is the only case where ICU and the JDK disagree, which matters when the same resource file is read by both.The ICU message editor shows the output of a message, which is a quick way to check a quoted pattern.
Published Oct 9, 2026 · Markdown version