1001Ferramentas
๐Ÿ“ Validators

ICU MessageFormat Syntax Validator

Analyze ICU MessageFormat messages detecting malformed placeholders, plurals missing the other case, missing select branches and invalid types.

Understanding ICU MessageFormat

ICU MessageFormat is the message syntax used for internationalization (i18n) by tools such as FormatJS / react-intl, MessageFormat.js, and the ICU4J / ICU4C libraries. It lets a single localized string adapt to runtime values โ€” counts, genders, currencies, dates โ€” without hardcoding grammar for each language. Validating a message means checking that braces are balanced and that every argument uses a known type with valid sub-syntax.

Placeholders and argument types

The simplest placeholder is just a name in braces: Hello, {name}!. Typed arguments add a type and options:

  • plural: {count, plural, one {# item} other {# items}}
  • select: {g, select, male {he} female {she} other {they}}
  • number: {n, number, ::currency/USD}
  • date / time: {d, date, short}
  • Other types include selectordinal and the deprecated choice.

Inside a plural block, the # symbol is replaced by the formatted count. Always provide an other branch โ€” it is the required fallback.

Escaping literals

Because braces and # are special, you escape literal characters with apostrophes. A single quote starts and ends a literal section, and '' produces a literal apostrophe. So '{not a placeholder}' renders the braces verbatim.

Common pitfalls

  • Unbalanced braces โ€” an opening { with no matching }.
  • Omitting the mandatory other branch in a plural or select.
  • Using an unknown argument type (e.g. foo instead of plural/select/number).
  • Forgetting that # only works inside a plural/selectordinal, not elsewhere.
  • Putting a literal apostrophe without doubling it, which silently starts an escape.

FAQ

What is the difference between plural and select? plural matches CLDR plural categories (one, other, etc.) for a number, while select matches arbitrary string keys you define, such as a gender value.

Why must I always include other? It is the guaranteed fallback when no other case matches, and languages differ wildly in their plural rules, so the parser enforces it.

Is choice safe to use? No โ€” the choice argument type is deprecated. Use plural or select instead.

Related Tools