Issue Feature Closed

#104546Support plural forms in language files

Daniel Ablass 08/04/24, 05:09 updated 03/31/26, 09:00

Description

This feature implements support of plural forms in language files. Units in XLIFF files can be grouped to define plural forms of a translation:

<group id="day" restype="x-gettext-plurals">
  <trans-unit id="day[0]">
    <source>%1$s day</source>
  </trans-unit>
  <trans-unit id="day[1]">
    <source>%1$s days</source>
  </trans-unit>
</group>

The number in [] defines the plural form as defined here: http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html
Behaviour of existing TYPO3 installations is not changed. To make use of the plural forms a new argument named quantity is introduced and handed all the way down from TranslateViewHelper over LocalizationUtility::translate to LanguageService->sL. TranslationService->translate supports the new argument, too.
If no quantity value is passed, the form [0] is used as default.
Examples:

<f:translate id="my.label" quantity="1" />
<f:translate arguments="{0: quantity}" id="my.label" quantity="{quantity}" />
$languageService->sL($id, 42);

At the suggestion of Georg Ringer, the ContentObjectRenderer also received support for this feature. The argument can be appended to the label in TypoScript seperated by a comma.
Example:

label = TEXT
label.data = LLL:EXT:my_ext/Resources/Private/Language/locallang.xlf:my.label,42

Translation cache takes the plural forms into account.

Reviews 4

History 925

  1. Gerrit Code Review pushed patch set 1 for main to change 85509 status Accepted Under Review <span data-processor="relativetime" data-value="2024-08-04T15:07:06+00:00" > 08/04/24, 15:07 </span>

  2. Riccardo De Contardi commented and changed status Under Review Closed <span data-processor="relativetime" data-value="2025-08-11T13:55:17+00:00" > 08/11/25, 13:55 </span>

    I close this issue in favor of https://forge.typo3.org/issues/104546 which has an ongoing patch attached (the one attached here looks abandoned); please continue the discussion there.

    Thank you.

  3. Benni Mack commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-02-23T19:25:09+00:00" > 02/23/26, 19:25 </span>

    Applied in changeset commit:7ac6c705af6d70ca4dd256961db3ca49830dba0b.