What is Pluralization?

Pluralization is choosing the right form of a message based on a count. English has two forms, "1 file" and "2 files", so developers are tempted to hack it with an if statement. Other languages break that hack immediately: some use one form for everything, while others, Russian and Arabic among them, have several forms selected by rules more complex than "equal to one".

The CLDR project defines standard plural categories per language: zero, one, two, few, many, and other. A proper i18n layer lets the translation itself declare which forms it needs, and picks the right one at runtime from the count and the active locale.

Laravel handles this with trans_choice() and a pipe syntax in the translation string, including exact-count and range segments. For more complex grammar, ICU MessageFormat plurals via the intl extension are the heavier-duty option. Note that ordinal numbers (1st, 2nd, 3rd) follow separate rules from cardinal counts.

// lang/en/messages.php
return [
    'apples' => '{0} No apples|{1} One apple|[2,*] :count apples',
];

trans_choice('messages.apples', 0);              // "No apples"
trans_choice('messages.apples', 7, ['count' => 7]); // "7 apples"

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