Project

General

Profile

Actions

Feature #104546

open

Support plural forms in language files

Added by Daniel Ablass 4 months ago. Updated about 1 month ago.

Status:
Under Review
Priority:
Should have
Assignee:
Category:
Localization
Start date:
2024-08-04
Due date:
% Done:

0%

Estimated time:
PHP Version:
8.2
Tags:
Complexity:
Sprint Focus:

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.


Related issues 1 (1 open0 closed)

Is duplicate of TYPO3 Core - Feature #73234: The ability to use plural in xlf filesUnder Review2016-02-11

Actions
Actions #1

Updated by Georg Ringer 4 months ago

  • Status changed from New to Accepted
Actions #2

Updated by Georg Ringer 4 months ago

  • Is duplicate of Feature #73234: The ability to use plural in xlf files added
Actions #3

Updated by Daniel Ablass 4 months ago

  • Assignee set to Daniel Ablass
Actions #4

Updated by Gerrit Code Review 4 months ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/85509

Actions #5

Updated by Gerrit Code Review 4 months ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/85509

Actions #6

Updated by Gerrit Code Review 4 months ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/85509

Actions #7

Updated by Gerrit Code Review 3 months ago

Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/85509

Actions #8

Updated by Benni Mack about 1 month ago

  • Target version changed from 13 LTS to Candidate for Major Version
Actions

Also available in: Atom PDF