Review main Abandoned

64911[FEATURE] Implement XLIFF pluralization forms "zero", "one" and "many"

Armin Vieweg CR 0 V 0 Normal +127 −9 updated 11/05/21, 08:39

Commit message

Example usage in Locallang.xlf:

<group restype="x-gettext-plurals">
    <trans-unit id="label.itemsFound[0]">
        <source>No items found.</source>
    </trans-unit>
    <trans-unit id="label.itemsFound[1]">
        <source>Found one item.</source>
    </trans-unit>
    <trans-unit id="label.itemsFound[2]">
        <source>Found %d items.</source>
    </trans-unit>
</group>

Example usage in Fluid template:
<f:translate key="label.itemsFound" arguments="{0: '{items -> f:count()}'}">

Overwrite pluralized translations example, using typoscript:
plugin.tx_myext._LOCAL_LANG.default.label.itemsFound._pluralize {
  0 = %d items found
  1 = 1 item found
  2 = %d items found
}

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 2

Review log 3145

Show 1220 earlier messages
  1. Armin Vieweg uploaded patch set 1 06/20/20, 12:36

  2. TYPO3com voted on patch set 1 V -1 06/20/20, 12:37 Completed build in 30s on Sat, 20 Jun, 12:37 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3961

  3. Armin Vieweg updated the commit message in patch set 2 06/20/20, 12:40

  4. TYPO3com voted on patch set 2 V -1 06/20/20, 12:40 Completed build in 24s on Sat, 20 Jun, 12:40 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3962

  5. Armin Vieweg updated the commit message in patch set 3 06/20/20, 12:41

  6. TYPO3com voted on patch set 3 V -1 06/20/20, 12:42 Completed build in 22s on Sat, 20 Jun, 12:42 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3963

  7. Armin Vieweg updated the commit message in patch set 4 06/20/20, 12:43

  8. TYPO3com voted on patch set 4 V -1 06/20/20, 12:43 Completed build in 23s on Sat, 20 Jun, 12:43 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3964

  9. TYPO3com commented on patch set 4 06/20/20, 13:12 Completed build in 25s on Sat, 20 Jun, 01:12 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3965

  10. Simon Gilli updated the commit message in patch set 5 06/20/20, 13:14

  11. TYPO3com voted on patch set 5 V -1 06/20/20, 13:14 Completed build in 29s on Sat, 20 Jun, 01:14 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3966

  12. Simon Gilli updated the commit message in patch set 6 06/20/20, 13:25

  13. TYPO3com voted on patch set 6 V -1 06/20/20, 13:25 Completed build in 26s on Sat, 20 Jun, 01:25 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3967

  14. Simon Gilli uploaded patch set 7 06/20/20, 13:29

  15. Oliver Klee commented on patch set 7 06/20/20, 13:34

    Can we please cover this with tests?
  16. Simon Gilli commented on patch set 7 06/20/20, 13:40

    > Patch Set 7: > > Can we please cover this with tests? Will take care...
  17. TYPO3com voted on patch set 7 V -1 06/20/20, 13:48 Completed build in 18m 43s on Sat, 20 Jun, 01:48 PM Test Summary: 72860 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3968

  18. Simon Gilli uploaded patch set 8 06/20/20, 14:17

  19. Simon Gilli uploaded patch set 9 06/20/20, 14:25

  20. Simon Gilli uploaded patch set 10 06/20/20, 14:26

  1. TYPO3com voted on patch set 8 V +1 06/20/20, 14:29 Completed build in 11m 55s on Sat, 20 Jun, 02:29 PM Test Summary: 72896 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3970

  2. TYPO3com voted on patch set 9 V -1 06/20/20, 14:40 Completed build in 15m 30s on Sat, 20 Jun, 02:40 PM Test Summary: 12 of 73383 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3971

  3. TYPO3com voted on patch set 10 V +1 06/20/20, 14:44 Completed build in 15m 57s on Sat, 20 Jun, 02:44 PM Test Summary: 72896 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3972

  4. Simon Gilli uploaded patch set 11 06/20/20, 14:56

  5. TYPO3com voted on patch set 11 V +1 06/20/20, 15:08 Completed build in 11m 50s on Sat, 20 Jun, 03:08 PM Test Summary: 72920 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3973

  6. Simon Gilli uploaded patch set 12 06/20/20, 15:12

  7. TYPO3com voted on patch set 12 V +1 06/20/20, 15:25 Completed build in 12m 41s on Sat, 20 Jun, 03:25 PM Test Summary: 72956 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3974

  8. Simon Gilli uploaded patch set 13 06/20/20, 16:30

  9. TYPO3com voted on patch set 13 V +1 06/20/20, 16:42 Completed build in 12m 11s on Sat, 20 Jun, 04:42 PM Test Summary: 72956 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3975

  10. Mathias Brodala commented on patch set 13 V -1 06/22/20, 07:15

    LocalizationUtility.php:355

    We need to implement a way to define plural forms depending on the language. The current implementation only covers languages like German and English. There are languages with way more complex plural forms like Polish or Arabic. See https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html
  11. Armin Vieweg commented on patch set 13 06/22/20, 12:00

    > Patch Set 13: Verified-1 > > (1 comment) I would suggest a new issue for that (which can idle for another 4 years). This approach is just a 80% solution, right. But imo it's better than no solution at all.
  12. Oliver Klee commented on patch set 13 06/22/20, 12:12

    LocalizationUtility.php:355 Reply

    Maybe we can provide intervals as keys like this? https://symfony.com/doc/2.7/components/translation/usage.html#pluralization
  13. Armin Vieweg commented on patch set 13 06/22/20, 14:43

    LocalizationUtility.php:355 Reply

    @Matthis Well, this issue was idle for 4 years. Probably because this topic is not that easy to implement. I'm offering a 80% solution, which are 80% more than the core currently has. I'm pretty sure, also in languages which have more plural forms, this patch could help. Unfortunately my brain is unable to handle more plural forms than English or German provides. If you insist on a 100% solution, I hope you also provide the solution. @Oli This would make it pretty flexible. I'm not sure if Xliff is supporting this syntax. Also the Xliff parser needs to get rewritten, then. Currently keys with 1 char length, are supported.
  14. Mathias Brodala commented on patch set 13 V 0 06/22/20, 14:56

    LocalizationUtility.php:355 Reply

    I never said that I would insist on anything, I just pointed out shortcomings which will lead to user confusion and reports. Since this is a more complex topic maybe this should be tackled in a dedicated i18n sprint instead. Some inspiration can be taken from Flow: https://flowframework.readthedocs.io/en/stable/TheDefinitiveGuide/PartIII/Internationalization.html#plural-forms https://github.com/neos/flow/blob/1f230531e6d61306b5e43c4d0bc3b569e7432e52/Resources/Private/I18n/CLDR/Sources/supplemental/plurals.xml
  15. Armin Vieweg commented on patch set 13 06/25/20, 06:19

    LocalizationUtility.php:355 Reply

    Well, you also voted for verified -1,which is a clear statement. Especially because it's wrong. The title promises three plural forms to be implement, which is the case, and which works. I think you did not even test this patch, you've rejected it instantly, because of missing plural forms. Because of missing 20%. Sure, we can postpone this topic for another four years. Perfection will not solve issues.
  16. Mathias Brodala commented on patch set 13 06/25/20, 06:28

    LocalizationUtility.php:355 Reply

    Technically not: "many" is only implemented for languages with basic plural forms. But since you clearly are not interested in tackling the remaining N% (not sure why you think that the current state covers 80% of the languages) we can stop the discussion here.
  17. Armin Vieweg commented on patch set 13 06/25/20, 07:21

    LocalizationUtility.php:355 Reply

    Good point. I'm just not that much experienced with this topic, as you apparently are. And I don't think it is a bad idea to implement a properly, enterprisy pluralization support. I'm just unable to deliver it. 80% is a guess. And not related to languages, but real usecases (for me, personally, it would fit 99,9% of my daily work). However, I understand your concerns. And I don't want to stop the discussion here. I think this is an important topic! "Tackling the remaining N%" is indeed something I'm afraid of. Especially when I think about the time, it will take to test all those plural forms. I really would appreciate a dedicated i18n sprint, with people involved, able to solve this issue. But it did not take place in the past 4 years. What did change (but this partial patch)?
  18. Georg Ringer commented on patch set 13 06/25/20, 11:22

    maybe we should implement an event there to have the option for others to deliver custom checks?
  19. Armin Vieweg commented on patch set 13 06/25/20, 11:35

    > Patch Set 13: > > maybe we should implement an event there to have the option for others to deliver custom checks? It is already easily possible to introduce new functionality here. You can supply your own LocalizationUtility and an own translate viewhelper, using the utility.
  20. Mathias Brodala commented on patch set 13 06/25/20, 13:03

    LocalizationUtility.php:355 Reply

    Maybe I'm underthinking (is that even a word?) things but wouldn't it be enough to integrate all known plural forms exactly here and consider an option to add custom rules for additional languages? We can also look for packages which implement all plural forms like https://packagist.org/packages/gettext/languages and https://packagist.org/packages/wikimedia/cldr-plural-rule-parser
  21. Oliver Klee commented on patch set 13 06/25/20, 14:30

    I'd be perfectly fine with an 80% solution if we make sure that we do not paint ourselves into a corner with that solution (i.e., we know for sure that implementing the remaining 20% does not introduce breaking changes to extensions using the existing 80% implementation).
  22. Armin Vieweg commented on patch set 13 06/25/20, 19:07

    @Mathias Your suggestion sounds great! So we make this method calling a new event. And provide a listener, which supports at least English/German. This event must also know the target language. And it must stop event propagation, when the target language matches. In the end we have several listeners registered, for each language(-set) one, right? Here I've found a nice comparison about most used languages and when which form applies: https://lingohub.com/blog/2019/02/pluralization
  23. Mathias Brodala commented on patch set 13 06/26/20, 06:41

    > Patch Set 13: > > @Mathias Your suggestion sounds great! So we make this method calling a new event. And provide a listener, which supports at least English/German. > > This event must also know the target language. And it must stop event propagation, when the target language matches. > > In the end we have several listeners registered, for each language(-set) one, right? Here I've found a nice comparison about most used languages and when which form applies: > https://lingohub.com/blog/2019/02/pluralization I wasn't actually thinking of events but if we use them we could implement the listener ourselves for basic languages just like you describe here. Indeed a basic listener could cover all basic languages. As soon as a plural form is set on the event, processing is stopped. And this could very well serve as a possible blueprint how to handle i18n in TYPO3 in general in the future.
  24. Benni Mack commented on patch set 13 07/20/20, 08:30

    Great stuff, Armin. Thanks for your contribution. If we manage this to get into LanguageService, all functionality (not just Extbase) can benefit from it.
  25. Benni Mack abandoned the change 11/05/21, 08:39

    I will abandon this change for the time being due to lack of activity