85509[FEATURE] Support plural forms in language files
Commit message
Review
-
Code review CR 0
-
Verified V -1
- core-ci -1 CI
Issues 2
Files 17
- typo3/sysext/core/Classes/Localization/LanguageService.php+37 −11
- typo3/sysext/core/Classes/Localization/PluralFormUtility.phpnew+223 −0
- typo3/sysext/core/Documentation/Changelog/14.2/Feature-104546-SupportPluralFormsInLanguageFiles.rstnew+93 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_localization/Resources/Private/Language/fr.locallang.xlf+10 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_localization/Resources/Private/Language/fr.messages_2.xlf+17 −7
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_localization/Resources/Private/Language/locallang.xlf+8 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_localization/Resources/Private/Language/messages_2.xlf+8 −0
- typo3/sysext/core/Tests/Functional/Localization/LanguageServiceTest.php+175 −1
- typo3/sysext/core/Tests/Unit/Localization/PluralFormUtilityTest.phpnew+40 −0
- typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php+4 −2
- typo3/sysext/fluid/Classes/ViewHelpers/TranslateViewHelper.php3+3 −1
- typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/test_translate/Resources/Private/Language/locallang.xlf+8 −0
- typo3/sysext/fluid/Tests/Functional/ViewHelpers/TranslateViewHelperTest.php+72 −0
- typo3/sysext/form/Classes/Service/TranslationService.php+7 −3
- typo3/sysext/form/Tests/Functional/Fixtures/Extensions/form_labels/Resources/Private/Language/locallang_form.xlf+8 −0
- typo3/sysext/form/Tests/Functional/Service/TranslationServiceTest.php+11 −0
- typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php2+11 −1
Review log 3848
Show 1923 earlier messages
-
Daniel Ablass uploaded patch set 1 08/04/24, 15:07
-
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
-
Chris Müller commented on patch set 1 08/04/24, 15:17
Feature-104546-SupportPluralFormsInLanguageFiles.rst:48seperated -> separated -
Daniel Ablass uploaded patch set 2
V -108/04/24, 15:30 -
Daniel Ablass uploaded patch set 3 08/04/24, 15:32
-
Daniel Ablass commented on patch set 3 08/04/24, 15:35
Feature-104546-SupportPluralFormsInLanguageFiles.rst:40ReplyDone. Good idea.Feature-104546-SupportPluralFormsInLanguageFiles.rst:48ReplyThanks. -
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
-
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
-
Daniel Ablass voted on patch set 3 V +1 08/04/24, 15:50
-
Daniel Ablass wrote 08/04/24, 15:51
Removed reviewer Daniel Ablass with the following votes: * Verified+1 by Daniel Ablass -
Simon Schaufelberger commented on patch set 3 08/06/24, 05:19
PluralFormUtility.php:183no alignment of parametersFeature-104546-SupportPluralFormsInLanguageFiles.rst:40ReplyDoneFeature-104546-SupportPluralFormsInLanguageFiles.rst:46no personal praise in documentationFeature-104546-SupportPluralFormsInLanguageFiles.rst:48ReplyDone -
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 -
Guido Schmechel commented on patch set 3 08/07/24, 04:30
PluralFormUtility.php:32Does it make sense to add tests for this class?PluralFormUtility.php:220Shouldn'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-languagesTranslateViewHelper.php:187Do we also need the ?? null query here? If the quantity argument has not been set. -
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:32ReplyI 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:183ReplyWill be corrected in next patchset. Thanks.PluralFormUtility.php:220ReplyThe "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:46ReplyWill be removed in next patchset.TranslateViewHelper.php:187ReplyThe argument is always set during the initialization of the ViewHelper and is already null when not provided as attribute in a template. -
Daniel Ablass uploaded patch set 4
V +108/11/24, 18:20 -
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
-
Guido Schmechel commented on patch set 4 08/18/24, 12:09
PluralFormUtility.php:183ReplyDone -
Guido Schmechel commented on patch set 4 08/18/24, 12:10
TranslateViewHelper.php:187ReplyDone -
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 youPluralFormUtility.php:220ReplyDone -
Guido Schmechel commented on patch set 4 08/18/24, 12:11
PluralFormUtility.php:32ReplyDone -
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/+/85502Feature-104546-SupportPluralFormsInLanguageFiles.rst:46ReplyDone -
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). -
Garvin Hicking commented on patch set 4 09/04/24, 19:52
Sadly no real review (yet), just first short thoughtsPluralFormUtility.php:32Maintaining 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:29ReST file needs some more syntax and :php: directives, linking (I can offer do that at some point, not blocking)ContentObjectRenderer.php:3939Theoretically, "," 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:1600add a test here for "lll:myext/resources/stuff,and-other/locallanf.xlf:long.key,42"? Alsoy add float keys here for tests?
-
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. -
Daniel Ablass uploaded patch set 5
V +111/22/24, 16:30 -
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
-
Daniel Ablass uploaded patch set 6
V +111/22/24, 17:33 -
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
-
Daniel Ablass uploaded patch set 7
V -111/22/24, 17:43 -
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
-
Daniel Ablass commented on patch set 7 11/26/24, 10:31
PluralFormUtility.php:32ReplyIt would be fine for me to create a separate package for this. I will tackle this next.Feature-104546-SupportPluralFormsInLanguageFiles.rst:29Reply UnresolvedThanks for offering your help. I'd highly appreciate that.ContentObjectRenderer.php:3939Reply UnresolvedGood point. I changed delimiter and logic to be more robust.ContentObjectRendererTest.php:1600Reply UnresolvedAdded some more test cases. -
Chris Müller wrote 11/26/24, 18:20
Removed cc Chris Müller. -
Simon Schaufelberger uploaded patch set 8
V +108/09/25, 23:16 -
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
-
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 -
Mathias Bolt Lesniak commented on patch set 8 08/11/25, 10:14
PluralFormUtility.php:32Reply UnresolvedThere should also be a way to change or extend the `LANGUAGE_RULE_MAPPING` array. PSR-14 event? -
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 -
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? -
Benni Mack uploaded patch set 9
V +101/22/26, 18:06 -
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
-
Benni Mack uploaded patch set 10
V -101/22/26, 18:58 -
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?) -
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 -
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
-
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? :) -
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. 😎 -
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 -
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
Feature-104546-SupportPluralFormsInLanguageFiles.rst:40