🎉 v1.0

Get started

  • Welcome
  • Documentation
  • Pricing
    Soon

Tools

  • I18n MCP
  • CLI
  • CI/CD Integrations
  • Compiler
    Alpha
  • Connect Your Engine

Resources

  • Languages
  • LLM Models
  • Guides

Company

  • Enterprise
  • CareersHiring!
Dashboard

Lingo.dev Compiler

  • How it works
  • Setup

Framework Integration

  • Next.js
  • Vite + React

Configuration

  • Configuration Reference
  • Translation Providers
  • Build Modes

Features

  • Manual Overrides
  • Custom Locale Resolvers
  • Automatic Pluralization
  • Locale Switching

Development

  • Development Tools
  • Project Structure

Guides

  • Best Practices
  • Migration Guide
  • Troubleshooting

Automatic Pluralization

Max PrilutskiyMax Prilutskiy·Updated 5 days ago·3 min read

Alpha

The Lingo.dev Compiler is in alpha. It is unstable, not recommended for production use, and APIs may change between releases.

The Lingo.dev Compiler detects plural forms in your JSX text and automatically converts them to ICU MessageFormat. Instead of manually writing plural rules for each language, write natural text with numeric values and the compiler generates the correct plural forms using an LLM.

How it works#

1

Compiler detects numeric patterns

During AST analysis, the compiler identifies text nodes that contain interpolated numbers alongside count-dependent words. For example, You have {count} items contains a numeric variable next to a word that changes with quantity.

2

LLM classifies plural forms

A small, fast LLM (configurable via pluralization.model) analyzes the text and determines which words need plural inflection. It generates the appropriate CLDR plural categories for each target locale.

3

ICU MessageFormat is generated

The compiler produces an ICU MessageFormat string that handles all plural categories required by the target language.

Example#

Source JSX:

tsx
<p>You have {count} items in your cart</p>

Generated output for English:

text
{count, plural, one {You have 1 item in your cart} other {You have # items in your cart}}

Generated output for Russian (which has four plural categories):

text
{count, plural, one {У вас # товар в корзине} few {У вас # товара в корзине} many {У вас # товаров в корзине} other {У вас # товаров в корзине}}

CLDR plural categories#

Different languages use different subsets of the six CLDR plural categories. The compiler generates only the categories required by each target locale:

CategoryDescriptionExample languages
zeroZero quantityArabic, Latvian
oneSingularEnglish, French, German, Spanish
twoDualArabic, Hebrew, Slovenian
fewPaucal / small quantityRussian, Czech, Polish
manyLarge quantityRussian, Arabic, Polish
otherGeneral / default (always required)All languages

English uses one and other. Russian uses one, few, many, and other. Arabic uses all six categories. The compiler handles this automatically per locale.

Configuration#

Pluralization is enabled by default. Configure it in the compiler options:

ts
{
  pluralization: {
    enabled: true,
    model: "groq:llama-3.1-8b-instant",
  },
}
OptionTypeDefaultDescription
pluralization.enabledbooleantrueEnable or disable automatic plural detection.
pluralization.modelstring"groq:llama-3.1-8b-instant"LLM model for plural form detection. A smaller model is sufficient since detection is simpler than translation.

To disable pluralization entirely:

ts
{
  pluralization: {
    enabled: false,
  },
}

Disabling pluralization means the compiler translates text containing numbers as plain strings. The translated output may not be grammatically correct for all quantities in languages with complex plural rules.

When pluralization applies#

The compiler detects plural patterns in these cases:

  • Text with interpolated numeric variables: {count} items, {n} messages
  • Text with numeric literals: You have 5 items (less common in dynamic UI)

The compiler does not pluralize:

  • Text with no numeric reference: Items in cart (no number to branch on)
  • Text where the number is not directly related to a count-dependent word

Write natural text in your JSX. The compiler and its LLM handle the plural detection and ICU formatting - you do not need to learn ICU MessageFormat syntax.

Next Steps#

Configuration Reference
All pluralization options
Translation Providers
Configure the LLM used for translation
Manual Overrides
Override specific translations when needed
Best Practices
When to enable or disable pluralization

Was this page helpful?