Review main Abandoned

85509[FEATURE] Support plural forms in language files

Daniel Ablass CR 0 V -1 Hard +735 −26 updated 02/24/26, 08:05

Commit message

It is now possible to define plural forms in language files and use them
via TranslationViewHelper, LocalizationUtility, LanguageService,
TranslationService and TypoScript (ContentObjectRenderer).
This allows labels to be formulated better without having to use
additional conditions.

Review

  • Code review CR 0
  • Verified V -1
    • core-ci -1 CI

Issues 2

Files 17

Review log 3848

Show 1923 earlier messages
  1. Daniel Ablass uploaded patch set 1 08/04/24, 15:07

  2. core-ci voted on patch set 1 V -1 08/04/24, 15:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62829

  3. Chris Müller commented on patch set 1 08/04/24, 15:17

    Feature-104546-SupportPluralFormsInLanguageFiles.rst:40

    I suggest to use "day" here instead of "my.label" to reflect the xliff example from above.

    Feature-104546-SupportPluralFormsInLanguageFiles.rst:48

    seperated -> separated
  4. Daniel Ablass uploaded patch set 2 V -1 08/04/24, 15:30

  5. Daniel Ablass uploaded patch set 3 08/04/24, 15:32

  6. Daniel Ablass commented on patch set 3 08/04/24, 15:35

    Feature-104546-SupportPluralFormsInLanguageFiles.rst:40 Reply

    Done. Good idea.

    Feature-104546-SupportPluralFormsInLanguageFiles.rst:48 Reply

    Thanks.
  7. core-ci voted on patch set 2 V +1 08/04/24, 15:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62830

  8. core-ci voted on patch set 3 V +1 08/04/24, 15:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62831

  9. Daniel Ablass voted on patch set 3 V +1 08/04/24, 15:50

  10. Daniel Ablass wrote 08/04/24, 15:51

    Removed reviewer Daniel Ablass with the following votes: * Verified+1 by Daniel Ablass
  11. Simon Schaufelberger commented on patch set 3 08/06/24, 05:19

    PluralFormUtility.php:183

    no alignment of parameters

    Feature-104546-SupportPluralFormsInLanguageFiles.rst:40 Reply

    Done

    Feature-104546-SupportPluralFormsInLanguageFiles.rst:46

    no personal praise in documentation

    Feature-104546-SupportPluralFormsInLanguageFiles.rst:48 Reply

    Done
  12. Simon Schaufelberger commented on patch set 3 08/06/24, 05:25

    please also link the other issues here as there are a few more under related
  13. Guido Schmechel commented on patch set 3 08/07/24, 04:30

    PluralFormUtility.php:32

    Does it make sense to add tests for this class?

    PluralFormUtility.php:220

    Shouldn't that be 2 if it is the default in the mapping? How do we deal with languages that have been registered and are not known here? Does an event make sense to influence the mapping? see https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Localization/ManagingTranslations.html#xliff-translating-languages

    TranslateViewHelper.php:187

    Do we also need the ?? null query here? If the quantity argument has not been set.
  14. Daniel Ablass commented on patch set 3 08/07/24, 19:15

    Reply

    Can they simply be appended as comma separated list (with or without whitespace)?

    PluralFormUtility.php:32 Reply

    I could think of a test for the language fallback. Example: If de_CH is not found as key in the mapping array, de is used. The test would assert that the result of the method is equal for de and de_CH.

    PluralFormUtility.php:183 Reply

    Will be corrected in next patchset. Thanks.

    PluralFormUtility.php:220 Reply

    The "default" key in the mapping array refers to the rule number that should be used. The default case of the match statement returns 0 because that is the default plural form (always starts from 0, regardless of language). This fallback is used for rule 0 and invalid rule indexes, which couldn't occur at the moment, but would be possible if an event for manipulation is added. I like that idea and will add it to a new patchset soon.

    Feature-104546-SupportPluralFormsInLanguageFiles.rst:46 Reply

    Will be removed in next patchset.

    TranslateViewHelper.php:187 Reply

    The argument is always set during the initialization of the ViewHelper and is already null when not provided as attribute in a template.
  15. Daniel Ablass uploaded patch set 4 V +1 08/11/24, 18:20

  16. core-ci voted on patch set 4 V +1 08/11/24, 18:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/63192

  17. Guido Schmechel commented on patch set 4 08/18/24, 12:09

    PluralFormUtility.php:183 Reply

    Done
  18. Guido Schmechel commented on patch set 4 08/18/24, 12:10

    TranslateViewHelper.php:187 Reply

    Done
  19. Guido Schmechel commented on patch set 4 08/18/24, 12:11

    As we will soon have Feature Freeze. Don't let the PSR14 event stop you

    PluralFormUtility.php:220 Reply

    Done
  20. Guido Schmechel commented on patch set 4 08/18/24, 12:11

    PluralFormUtility.php:32 Reply

    Done
  21. Guido Schmechel commented on patch set 4 08/18/24, 12:17

    Reply

    Each related issue has its own line, see https://review.typo3.org/c/Packages/TYPO3.CMS/+/85502

    Feature-104546-SupportPluralFormsInLanguageFiles.rst:46 Reply

    Done
  22. Daniel Ablass commented on patch set 4 08/18/24, 19:38

    Reply Unresolved

    Done. I didn't find any other related issues than that added in current patchset (#73234).
  23. Garvin Hicking commented on patch set 4 09/04/24, 19:52

    Sadly no real review (yet), just first short thoughts

    PluralFormUtility.php:32

    Maintaining this in the TYPO3 core somehow feels odd. Shouldn't this be a seperate package that we can set a dependency on?

    Feature-104546-SupportPluralFormsInLanguageFiles.rst:29

    ReST file needs some more syntax and :php: directives, linking (I can offer do that at some point, not blocking)

    ContentObjectRenderer.php:3939

    Theoretically, "," could be part of a filename or directory. So maybe use a match that goes from the end of $key instead of matching from the beginning, which would then break the pass to LLL?

    ContentObjectRendererTest.php:1600

    add a test here for "lll:myext/resources/stuff,and-other/locallanf.xlf:long.key,42"? Alsoy add float keys here for tests?
  1. Stefan Bürk commented on patch set 4 09/04/24, 21:01

    This needs confirmation from the translation team if crowdin supports the "group"/"plural" syntax first.
  2. Daniel Ablass uploaded patch set 5 V +1 11/22/24, 16:30

  3. core-ci voted on patch set 5 V +1 11/22/24, 16:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70057

  4. Daniel Ablass uploaded patch set 6 V +1 11/22/24, 17:33

  5. core-ci voted on patch set 6 V -1 11/22/24, 17:40 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70060

  6. Daniel Ablass uploaded patch set 7 V -1 11/22/24, 17:43

  7. core-ci voted on patch set 7 V +1 11/22/24, 17:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70061

  8. Daniel Ablass commented on patch set 7 11/26/24, 10:31

    PluralFormUtility.php:32 Reply

    It would be fine for me to create a separate package for this. I will tackle this next.

    Feature-104546-SupportPluralFormsInLanguageFiles.rst:29 Reply Unresolved

    Thanks for offering your help. I'd highly appreciate that.

    ContentObjectRenderer.php:3939 Reply Unresolved

    Good point. I changed delimiter and logic to be more robust.

    ContentObjectRendererTest.php:1600 Reply Unresolved

    Added some more test cases.
  9. Chris Müller wrote 11/26/24, 18:20

    Removed cc Chris Müller.
  10. Simon Schaufelberger uploaded patch set 8 V +1 08/09/25, 23:16

  11. core-ci voted on patch set 8 V +1 08/09/25, 23:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83077

  12. Stefan Bürk commented on patch set 8 08/10/25, 23:13

    Reply Unresolved

    + restfile needs to be moved as that would be not a late 13.3 feature
  13. Mathias Bolt Lesniak commented on patch set 8 08/11/25, 10:14

    PluralFormUtility.php:32 Reply Unresolved

    There should also be a way to change or extend the `LANGUAGE_RULE_MAPPING` array. PSR-14 event?
  14. Peter Kraume commented on patch set 8 08/28/25, 12:42

    I haven't checked the technical implementation of this patch; rather, I've checked its effects on xlf file translations with Crowdin, as well as whether our Crowdin Bridge can handle groups. From what I can tell, both Crowdin and the Bridge support the new feature. https://store.crowdin.com/xliff https://github.com/TYPO3/crowdin-bridge
  15. Benni Mack commented on patch set 8 09/12/25, 20:55

    sorry to jump in late to the party.. I tried to integrate symfony/translate so we can utilize ICU-snytax for plural. See https://unicode-org.github.io/icu/userguide/format_parse/messages/#complex-argument-types - symfony can utilize this as well. what do you think?
  16. Benni Mack uploaded patch set 9 V +1 01/22/26, 18:06

  17. core-ci voted on patch set 9 V -1 01/22/26, 18:25 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94079

  18. Benni Mack uploaded patch set 10 V -1 01/22/26, 18:58

  19. Benni Mack commented on patch set 10 01/22/26, 19:04

    Chiming in here again. I updated this implementation, which is now a tiny bit easier to read, as the XLIFF parser can deal with the plural forms now properly with XLIFF 1 + 2. Going with this patch means that we do _not_ use ICU-based message formats. it's a lightweight implementation for the existing XLIFF-based translation system that doesn't require the intl PHP extension. The ICU approach would require: - PHP intl extension (not always available) - Different XLIFF format (ICU message strings) - Breaking changes to existing translations I also prepared a version which is based on the ICU approach, for the following reasons: 1. ICU is an international standard 2. Maintained externally - Plural rules are updated by Unicode/ICU 3. Handles gender, ordinals, and select patterns, not just plurals 4. Locale-aware - Built-in knowledge of all language plural rules 5. We already require php-intl (which is new since v12 I guess?)
  20. Mathias Bolt Lesniak commented on patch set 10 01/22/26, 19:08

    Reply

    @benni@typo3.org The PHP intl extension is listed as a requirement in the docs. It follows that it should always be available. Or we need to update the docs. https://docs.typo3.org/permalink/t3coreapi:system-requirements-php-extensions
  21. core-ci voted on patch set 10 V -1 01/22/26, 19:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94083

  22. Benni Mack commented on patch set 10 01/22/26, 19:52

    Reply

    @mathias.bolt.lesniak@typo3.org I don't understand your question? Or was it a question? :)
  23. Mathias Bolt Lesniak commented on patch set 10 01/22/26, 20:05

    Reply

    @benni@typo3.org Just a small possible inconsistency I picked up on. You wrote: "PHP intl extension (not always available)" If it's not always available, it can't be a requirement. 😎
  24. Benni Mack commented on patch set 10 01/22/26, 20:12

    Reply Unresolved

    got it. it's now always available :) In general, I think the localization team should decide now which approach is possible with CrowdIn or better supported in general https://review.typo3.org/c/Packages/TYPO3.CMS/+/92468
  25. Garvin Hicking abandoned the change 02/24/26, 08:05

    The "other" variant has now been merged: https://review.typo3.org/c/Packages/TYPO3.CMS/+/92468