Inferensys

Glossary

ICU MessageFormat

ICU MessageFormat is a Unicode technical standard that provides a structured, extensible syntax for resolving complex localization challenges—such as plural rules, gender inflection, and selection—within translatable strings at runtime.
Compute infrastructure aisle representing runtime, scale, and model serving.
LOCALIZATION STANDARD

What is ICU MessageFormat?

A Unicode technical standard providing a structured, extensible syntax for handling the grammatical and formatting complexities of different languages within software strings.

ICU MessageFormat is a Unicode standard that defines a structured syntax for creating dynamic, grammatically correct messages in software. It solves the problem of hard-coded string concatenation, which fails to account for the complex plural rules, gender inflection, and selection logic required by different languages. The format uses curly braces {} to define placeholders that are parsed and formatted at runtime by a dedicated library, ensuring a single source string can adapt to multiple linguistic contexts.

The standard supports advanced argument types like plural, select, and selectordinal, enabling a single message to handle variations such as "1 item" versus "2 items" without fragmenting the string. This moves localization logic out of brittle application code and into the translatable string itself, allowing translators to manage grammatical rules directly. By separating the message structure from the formatting logic, ICU MessageFormat is the foundational technology for achieving true internationalization (i18n) in modern, data-driven applications.

SYNTAX & MECHANISMS

Core Features of ICU MessageFormat

The ICU MessageFormat standard provides a structured, extensible syntax for resolving the complex grammatical and formatting challenges inherent in software localization, moving far beyond simple string concatenation.

01

Plural & Ordinal Selection

Handles the complex plural rules of different languages using CLDR data. The plural argument type selects the correct message variant based on a numeric value and its plural category (e.g., one, few, many, other).

  • Example: {count, plural, =0 {No items} one {# item} other {# items}}
  • The # token is automatically replaced with the numeric value, formatted with locale-appropriate number formatting.
  • Ordinal selection (selectordinal) handles categories like one, two, few for ranking strings (e.g., "1st", "2nd", "3rd").
02

Gender & Select Arguments

The select argument type enables gender inflection and other arbitrary keyword-based selections. It matches a provided string value against a set of explicit cases.

  • Example: {gender, select, male {He} female {She} other {They}} will reply soon.
  • Unlike plurals, select does not interpret the value; it performs a strict string match against the provided keys.
  • This mechanism is essential for languages with grammatical gender that affects surrounding adjectives and verbs.
03

Date, Time, & Number Formatting

Provides built-in argument types for locale-aware formatting of dates, times, and numbers without requiring pre-formatted strings.

  • Numbers: {price, number, ::currency/USD} formats a value as currency with the correct symbol and decimal separator.
  • Dates: {dueDate, date, ::yyyyMMMMdd} outputs a date using locale-specific month names.
  • Duration: {duration, duration, ::h:mm} formats a time interval.
  • These formatters use skeletons (like ::currency/USD) for precise, locale-independent control over the output pattern.
04

Nested & Complex Messages

MessageFormat supports arbitrary nesting of argument types, enabling the resolution of highly complex grammatical dependencies within a single translatable string.

  • A plural rule can contain a select argument, which can itself contain another plural rule.
  • Example: {count, plural, one {{gender, select, male {He has one item} female {She has one item} other {They have one item}}} other {They have # items}}
  • This composability allows linguists to model the full complexity of grammatical agreement without requiring developers to concatenate fragmented strings.
05

Quoting & Escaping Rules

A robust escaping syntax ensures that special characters used by the MessageFormat parser can appear as literal text in the output.

  • Single quotes ' denote literal text: This '{curly}' is literal outputs This {curly} is literal.
  • A single quote itself is escaped by doubling it: ''.
  • Within a quoted sequence, all characters—including braces { } and hash symbols #—are treated as plain text and not as syntax tokens.
  • This is critical for including apostrophes in languages like French and English without breaking the parser.
06

Custom Formatters & Extensibility

The ICU standard allows implementations to define custom formatter functions beyond the built-in number, date, and time types.

  • A custom formatter is invoked using the syntax: {value, formatterName, arg1, arg2}.
  • This enables domain-specific formatting like ordinal numbers ({pos, ordinal}) or spellout ({num, spellout}).
  • Implementations like intl-messageformat in JavaScript provide hooks for registering user-defined formatters, making the syntax extensible for proprietary formatting logic.
LOCALIZATION METHOD COMPARISON

ICU MessageFormat vs. Traditional String Concatenation

A technical comparison of structured message formatting versus imperative string building for handling plurals, gender, and selection in translatable user interfaces.

FeatureICU MessageFormatString ConcatenationTemplate Literals

Plural Rules Handling

Gender Inflection

Select Ordinals (1st, 2nd, 3rd)

Translator-Friendly Syntax

Runtime Parsing Required

Source String Extractability

Grammatical Agreement Across Arguments

Typical Bundle Size Overhead

< 5 KB

0 KB

0 KB

ICU MESSAGEFORMAT

Frequently Asked Questions

Clear, technical answers to the most common questions about the Unicode ICU MessageFormat standard, its syntax, and its role in solving complex localization challenges like pluralization and gender inflection.

ICU MessageFormat is a Unicode technical standard that provides a structured, extensible syntax for handling complex localization challenges—such as plural rules, gender inflection, and selection—directly within translatable strings. It works by embedding special formatting directives within curly braces {} inside a message string. At runtime, a formatting engine parses this syntax, evaluates the provided arguments against the rules defined in the Unicode Common Locale Data Repository (CLDR), and assembles the final, grammatically correct string. Unlike simple string concatenation or placeholder replacement, ICU MessageFormat allows a single source string to dynamically adapt its structure based on the numeric value or gender of an argument, eliminating the need for conditional logic in the application code and making the string fully translatable by linguists without developer intervention.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.