What is ICU MessageFormat?

ICU MessageFormat is a syntax for translatable messages that need logic: plurals, gender or other select branches, and typed placeholders for numbers and dates. It comes from ICU (International Components for Unicode), the library that implements much of the CLDR data, and it has been adopted well beyond C and Java, notably in the JavaScript ecosystem.

The core idea is that the branching lives inside the translation, not in code. A message like "{count, plural, one {# file} other {# files}}" lets a Russian translator supply the extra plural forms Russian needs without any code change. Select branches do the same for gender or arbitrary enumerations, and arguments can carry formatting types like number or date.

In PHP, the intl extension exposes this as MessageFormatter, so you can use ICU messages inside a Laravel app even though the framework native syntax is the simpler pipe format of trans_choice(). Teams usually adopt ICU when they localize into languages with rich plural systems or need gendered messages.

$msg = '{count, plural, one {# file} other {# files}} deleted';

MessageFormatter::formatMessage('en', $msg, ['count' => 1]); // "1 file deleted"
MessageFormatter::formatMessage('en', $msg, ['count' => 4]); // "4 files deleted"

Put the theory to work

LangSyncer manages your Laravel translations live: import lang files, translate with AI and publish without a deploy.

We use cookies to improve your experience and analyze site traffic. Cookie Policy

Cookie Preferences

Essential

Required for the site to work

Analytics

Help us improve the site

Marketing

Personalized ads and content