81696[FEATURE] Allow custom translations for extbase validators
Commit message
Review
-
Code review CR +2 Done
- Benni Mack +2
- Garvin Hicking +1
- Simon Schaufelberger +1
-
Verified V +2 Done
- Benni Mack +2
- Oliver Klee +1
- Garvin Hicking +1
- Simon Schaufelberger +1
- core-ci +1 CI
Issues 1
Files 23
- typo3/sysext/core/Documentation/Changelog/13.2/Deprecation-102326-RegularExpressionValidatorValidatorOptionErrorMessage.rstnew+71 −0
- typo3/sysext/core/Documentation/Changelog/13.2/Feature-102326-AllowCustomTranslationsForExtbaseValidators.rstnew+74 −0
- typo3/sysext/extbase/Classes/Validation/Validator/AbstractValidator.php2+29 −3
- typo3/sysext/extbase/Classes/Validation/Validator/AlphanumericValidator.php+7 −1
- typo3/sysext/extbase/Classes/Validation/Validator/BooleanValidator.php+10 −12
- typo3/sysext/extbase/Classes/Validation/Validator/DateTimeValidator.php+8 −2
- typo3/sysext/extbase/Classes/Validation/Validator/EmailAddressValidator.php+7 −7
- typo3/sysext/extbase/Classes/Validation/Validator/FloatValidator.php+7 −7
- typo3/sysext/extbase/Classes/Validation/Validator/IntegerValidator.php+7 −7
- typo3/sysext/extbase/Classes/Validation/Validator/NotEmptyValidator.php+14 −28
- typo3/sysext/extbase/Classes/Validation/Validator/NumberRangeValidator.php2+10 −9
- typo3/sysext/extbase/Classes/Validation/Validator/NumberValidator.php+7 −7
- typo3/sysext/extbase/Classes/Validation/Validator/RegularExpressionValidator.php+14 −7
- typo3/sysext/extbase/Classes/Validation/Validator/StringLengthValidator.php+15 −6
- typo3/sysext/extbase/Classes/Validation/Validator/StringValidator.php+7 −7
- typo3/sysext/extbase/Classes/Validation/Validator/TextValidator.php+7 −7
- typo3/sysext/extbase/Classes/Validation/Validator/UrlValidator.php+7 −7
- typo3/sysext/extbase/Resources/Private/Language/locallang.xlf+0 −9
- typo3/sysext/extbase/Tests/Functional/Validation/Validator/NumberValidatorTest.php+0 −1
- typo3/sysext/extbase/Tests/Functional/Validation/Validator/RegularExpressionValidatorTest.php+9 −10
Review log 5979
Show 3854 earlier messages
-
Torben Hansen uploaded patch set 1 11/06/23, 15:03
-
core-ci voted on patch set 1 V -1 11/06/23, 16:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48662
-
Torben Hansen uploaded patch set 2
V -111/06/23, 17:45 -
core-ci voted on patch set 2 V +1 11/06/23, 17:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48666
-
Torben Hansen updated the commit message in patch set 3
V +111/06/23, 18:15 -
core-ci voted on patch set 3 V +1 11/06/23, 18:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48667
-
Torben Hansen updated the commit message in patch set 4
V +111/07/23, 08:29 -
core-ci voted on patch set 4 V +1 11/07/23, 08:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48677
-
Garvin Hicking commented on patch set 4 11/07/23, 09:41
Personally, I love the idea. We (my team) usually had to copy+paste these as our own custom validators. That is a valid ;) way to go, since Validators aren't usually that big. But it creates redundancy, and we'd rather stay closer to the core. It makes attributes possibly feel a bit "bloated". But since it's totally optional, I don't see too much harm in this right now. Curious what others say. So, I'm totally in favor of pursueing this, thanks for this initiative! -
Torben Hansen rebased onto patch set 5
V +111/10/23, 17:04 -
core-ci voted on patch set 5 V +1 11/10/23, 17:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48796
-
Torben Hansen uploaded patch set 6
V +111/11/23, 13:00 -
Torben Hansen commented on patch set 6 11/11/23, 13:02
Reply
Thanks for your feedback. I uploaded an improved patch which avoids code duplication in the `setOptions()` function so validators look less "bloated". -
core-ci voted on patch set 6 V -1 11/11/23, 13:10 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48811
-
Torben Hansen uploaded patch set 7
V -111/11/23, 13:20 -
core-ci voted on patch set 7 V +1 11/11/23, 13:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48812
-
Torben Hansen wrote 11/11/23, 13:44
Topic set to extbase -
Torben Hansen rebased onto patch set 8
V +111/22/23, 12:45 -
core-ci voted on patch set 8 V +1 11/22/23, 12:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/49347
-
Torben Hansen rebased onto patch set 9
V +112/02/23, 14:08 -
core-ci voted on patch set 9 V +1 12/02/23, 14:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50249
-
Simon Schaufelberger voted on patch set 9 CR +1 12/22/23, 01:11
-
Oliver Klee voted on patch set 9 V +1 12/22/23, 09:44
-
Guido Schmechel commented on patch set 9 01/19/24, 20:45
Feature-102326-AllowCustomTranslationsForExtbaseValidators.rst:66locallang_custom.xlfNumberRangeValidator.php:37Maybe "notInRangeTranslateKey"? -
Torben Hansen uploaded patch set 10
CR +1V +101/20/24, 06:22 -
Torben Hansen commented on patch set 9 01/20/24, 06:22
Feature-102326-AllowCustomTranslationsForExtbaseValidators.rst:66ReplyDoneNumberRangeValidator.php:37ReplyAgree, the `notInRangeTranslateKey` fits better here. -
core-ci voted on patch set 10 V +1 01/20/24, 06:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/51838
-
Guido Schmechel voted on patch set 10 CR +1 01/20/24, 08:56
-
Garvin Hicking voted on patch set 10 CR +1 01/20/24, 10:06
-
Benni Mack commented on patch set 10 01/23/24, 22:16
How about we change this to become more flexible. Instead of the $key and $extensionName, we could use a id such as "LLL:my_ext..." - we would need a new method next to translateErrorMessage(), or maybe just use LocalizationUtility directly? I think this might be beneficial to streamline the logic here and allow for overriding them via one line -
Torben Hansen commented on patch set 10 01/24/24, 07:28
Reply
The `LLL:EXT:` syntax is already supported here, so it is possible to override the translations with one line (also see examples in Feature RST). I however implemented both the `LLL:EXT:` syntax as well as the id + extensionName option here, since the latter would result in shorter line length for validator configuration and maybe also better readability. So basically developers have a choice to use one of both options. I'm also fine to change this patch as you suggested and remove the `$extensionName` option again. What do you think? -
Benni Mack commented on patch set 10 01/24/24, 09:07
Reply
yes. let's remove $extensionName again. The reason why is the following. Working with $extensionName and a simple labelKey is a problem because then the file would have to be named "locallang.xlf" and I would like to reduce this logic (and rather implement a new one based on Symfony/Translator, but that's another story, I have a ticket for this) -
Chris Müller uploaded patch set 11
CR +1V +101/30/24, 18:59 -
core-ci voted on patch set 11 V +1 01/30/24, 19:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52509
-
Torben Hansen uploaded patch set 12
V +102/01/24, 08:53 -
Torben Hansen commented on patch set 12 02/01/24, 08:56
Reply
Done. Now we always use `LLL:EXT:` schema -
core-ci voted on patch set 12 V +1 02/01/24, 08:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52572
-
Guido Schmechel voted on patch set 12 CR +1 V +1 02/01/24, 16:22
-
Simon Schaufelberger commented on patch set 12 02/02/24, 12:14
Deprecation-102326-RegularExpressionValidatorValidatorOptionErrorMessage.rst:19and will beDeprecation-102326-RegularExpressionValidatorValidatorOptionErrorMessage.rst:50one space at the end can be removed -
Torben Hansen uploaded patch set 13
CR +1V +102/02/24, 12:49 -
Torben Hansen commented on patch set 12 02/02/24, 12:49
Deprecation-102326-RegularExpressionValidatorValidatorOptionErrorMessage.rst:19ReplyDoneDeprecation-102326-RegularExpressionValidatorValidatorOptionErrorMessage.rst:50ReplyDone -
core-ci voted on patch set 13 V +1 02/02/24, 12:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52632
-
Oliver Klee voted on patch set 13 V +1 02/02/24, 13:12
-
Simon Schaufelberger voted on patch set 13 CR +1 V +1 02/02/24, 13:53
-
Guido Schmechel voted on patch set 13 CR +1 V +1 02/02/24, 22:18
-
Benni Mack voted on patch set 13 CR +1 02/05/24, 12:08
-
Torben Hansen uploaded patch set 14
CR +1V +102/27/24, 17:42 -
core-ci voted on patch set 14 V -1 02/27/24, 17:48 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53652
-
Torben Hansen uploaded patch set 15
V -102/27/24, 17:52 -
core-ci voted on patch set 15 V -1 02/27/24, 17:59 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53655
-
Torben Hansen uploaded patch set 16
V -102/27/24, 18:04 -
core-ci voted on patch set 16 V +1 02/27/24, 18:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53659
-
Simon Schaufelberger voted on patch set 16 CR +1 V +1 03/20/24, 23:01
-
Jörg Bösche voted on patch set 16 CR +1 03/25/24, 11:52
-
Mathias Brodala commented on patch set 16 03/27/24, 09:15
How about using "*Message" instead, similar to Symfony? See https://symfony.com/doc/current/validation/translations.html This would make it clear that using static strings instead of l10n references is also fine. -
Torben Hansen commented on patch set 16 03/27/24, 09:20
Reply
You mean `message` instead of `translateKey`? If yes, I`m fine with that. For validators with multiple messages (e.g. NumberRangeValidator), we can use `message` as postfix (e.g. `notValidMessage` and `notInRangeMessage`) -
Torben Hansen uploaded patch set 17
CR +1V +103/28/24, 18:10 -
core-ci voted on patch set 17 V +1 03/28/24, 18:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55041
-
Torben Hansen commented on patch set 17 03/28/24, 18:19
Reply
Renamed the option and updated RST files. -
Mathias Brodala commented on patch set 17 04/02/24, 12:03
AbstractValidator.php:128This should be updated or removed, the method does more than this by now. -
Torben Hansen uploaded patch set 18
V +104/02/24, 17:51 -
Torben Hansen commented on patch set 18 04/02/24, 17:52
AbstractValidator.php:128ReplyDone -
Simon Schaufelberger wrote 04/02/24, 17:52
Removed reviewer Simon Schaufelberger. -
core-ci voted on patch set 18 V +1 04/02/24, 17:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55187
-
Guido Schmechel voted on patch set 18 CR +1 V +1 04/03/24, 10:02
-
Jörg Bösche voted on patch set 18 CR +1 04/04/24, 06:31
-
Garvin Hicking commented on patch set 18 CR +1 V +1 04/05/24, 10:05
FINALLY had the time to actually test this, works, and looks like a very nice convenience. Thanks for staying on it and iterating to the current solution! In the commit message there's a reference left to the initial variant `translateKey` that needs to be addapted to `messages`. Other than that, a few minor RST-comments.Deprecation-102326-RegularExpressionValidatorValidatorOptionErrorMessage.rst:45The old changelogs and most of the documentation often uses: `use TYPO3\CMS\Extbase\Annotation as Extbase;` and then `#[Extbase\Validate([` instead. Maybe it would be good to follow that (see i.e. `typo3/sysext/extbase/Tests/Unit/Reflection/Fixture/DummyController.php` or `typo3/sysext/core/Documentation/Changelog/12.0/Feature-96688-AttributesForExtbaseAnnotations.rst`. Using the probably more common syntax (albeit longer) might people better help to grep their sources for a needed change. Another thing: You only describe this using PHP attributes. Would mentioning the alternative of phpDoc comments be worthwile here, also to allow people easier spotting @Validate(...) / @Extbase\Validate(...) notations they would need to adapt?Feature-102326-AllowCustomTranslationsForExtbaseValidators.rst:15Maybe strike this one "by validators" to have the sentence with only 2x "validator" words. I appreciate the specificity of this though!Feature-102326-AllowCustomTranslationsForExtbaseValidators.rst:20Maybe add an example of those instances: "(like `Boolean`, `NotEmpty`, `NumberRange`)".Feature-102326-AllowCustomTranslationsForExtbaseValidators.rst:29(see other comment about the `Extbase\Validate` usage instead) -
Torben Hansen uploaded patch set 19
CR +1V +104/12/24, 09:11 -
Torben Hansen commented on patch set 18 04/12/24, 09:11
Deprecation-102326-RegularExpressionValidatorValidatorOptionErrorMessage.rst:45ReplyChanged. I would hovever not mention `@Extbase\Validate` here any more, since IMO php attributes should be the way to go.Feature-102326-AllowCustomTranslationsForExtbaseValidators.rst:15ReplyDoneFeature-102326-AllowCustomTranslationsForExtbaseValidators.rst:20ReplyDoneFeature-102326-AllowCustomTranslationsForExtbaseValidators.rst:29ReplyDone -
core-ci voted on patch set 19 V +1 04/12/24, 09:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55844
-
Garvin Hicking voted on patch set 19 CR +1 V +1 04/12/24, 09:40
-
Guido Schmechel voted on patch set 19 CR +1 V +1 04/12/24, 12:12
-
Torben Hansen uploaded patch set 20
CR +1V +104/27/24, 13:00 -
core-ci voted on patch set 20 V +1 04/27/24, 13:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56854
-
Garvin Hicking voted on patch set 20 CR +1 V +1 04/27/24, 19:47
-
Oliver Klee voted on patch set 20 V +1 04/28/24, 07:53
-
Simon Schaufelberger voted on patch set 20 CR +1 V +1 04/29/24, 09:28
-
Benni Mack voted on patch set 20 CR +2 V +2 06/07/24, 10:34
-
Benni Mack merged patch set 21 06/07/24, 10:34