Skip to main navigation Skip to main content Skip to page footer
TYPO3 14.2: Correctly solve plural forms in translations with ICU MessageFormat

TYPO3 14.2: Correctly solve plural forms in translations with ICU MessageFormat

Have the article read aloud.

Loading the Elevenlabs Text to Speech AudioNative Player...
| Estimated reading time : min.
This article was automatically translated using DeepL. Therefore, inaccuracies may occur.

Correctly mapping plural forms in TYPO3 translations used to be cumbersome. TYPO3 14.2 solves this with native ICU MessageFormat support directly in the translation infrastructure.

Anyone who builds translations with quantities knows the problem. "1 file found" and "3 files found" are not simply the same string with a different number. There are different forms depending on the language: English distinguishes two (singular and plural), Russian distinguishes four, Arabic even six. Mapping this cleanly in TYPO3 was previously cumbersome. As of version 14.2, there is a clean solution: ICU MessageFormat.

The previous problem

TYPO3 uses XLIFF files for translations. These have no built-in pluralization logic. Previously, if you wanted to map "1 file / 3 files" correctly, you either had to create two separate strings and control the selection in the code or use third-party libraries. Both are error-prone and difficult to maintain, especially when translators edit the files.

Incidentally, the problem is not specific to TYPO3. Many other platforms and frameworks still do not have an elegant answer to this problem.

What TYPO3 14.2 brings

As of 14.2, TYPO3 supports the ICU MessageFormat standard directly in the translation infrastructure. ICU (International Components for Unicode) is an established international standard that was developed precisely for such cases: Pluralization, gender-specific texts, conditional output.

The special feature: the system automatically recognizes which format should be used. If you pass named arguments, ICU MessageFormat is used. If you pass positional arguments, the classic sprintf is still used. Existing translations do not need to be touched.

For whom is this relevant?

Anyone who builds their own extensions or site packages with translations that contain quantities is directly affected. Typical use cases:

  • Output such as "1 result" / "5 results" in a search
  • Confirmation messages with counting ("You have 1 message" / "You have 3 messages")
  • Multilingual projects that benefit customers in languages with complex plural rules such as Russian, Arabic or Polish

Anyone who only translates static texts and never works with quantities will not notice this feature.

How it works

The plural rules are stored directly in the XLIFF file. The format follows the ICU standard and looks like this, for example: {count, plural, one {# file} other {# files}}. In the PHP code or Fluid template, you then pass named arguments instead of positional arguments. This is sufficient for TYPO3 to automatically use ICU MessageFormat.

All details on syntax, configuration and Fluid usage can be found in the changelog entry for feature #104546.

Classification

The feature requires the PHP intl extension, which is active by default on modern servers.

As with other TYPO3 14.2 features, the old ways still work. If you don't need pluralization in your translations, you don't need to change anything. Those who do need it now have a clean, standardized solution instead of workarounds.

Further innovations from TYPO3 14.2 that are relevant for integrators:


I continue to keep an eye on the relevant innovations from the TYPO3 14.2 changelog. If you don't want to miss an article, subscribe to my TYPO3 newsletter.

Of course, there will also be another comprehensive video course on TYPO3 v14 as soon as the LTS version is released. If you want to be informed about the launch and benefit from the discounted introductory price, sign up for the waiting list.

Back

Do you have a question or want to discuss the topic?

In the Community Hub for TYPO3 you can exchange ideas with other TYPO3 users. And if you don't want to miss any new articles: The TYPO3 Newsletter comes once a month, without spam.

Hi, I'm Wolfgang.

I have been working with TYPO3 since 2006. Not in theory, but in real projects with real deadlines. I've probably had the problems you're having three times already.

At some point, I started putting my knowledge into video courses. Not because I like being in front of the camera, but because I kept hearing the same questions over and over again. There are now hundreds of videos. Every single one was the result of a specific question from a specific project.

What makes me different from a YouTube tutorial: I not only know the solution, but also the context. Why something works. When it doesn't work. And which mistakes you can avoid because I've already made them.

My participants use me as a sparring partner. Not in the sense of "call me anytime", but like this: You come to the live session with a specific problem, post your question in the community or watch the appropriate video. And get an answer that works because it comes from practical experience.

As a member of the TYPO3 Education & Certification Committee, I make sure that the certification exams are kept up to date. What is tested there flows directly into my courses.