Review main Merged

91614[TASK] Add CLI command and service to search labels

Lina Wolf CR +2 V +2 Hard +472 −11 updated 11/18/25, 18:12

Commit message

A new console command `language:domain:search` has been
introduced to help developers and extension authors locate
translation labels and label references across TYPO3 extensions.

The command scans all language resource files (XLIFF) within active or
specific extensions and supports searching by plain string or regular
expression. It can output results as a table or JSON and includes
options to limit, crop, or flatten results.

This command is especially useful during the ongoing label
consolidation and cleanup process for TYPO3 v14, helping developers
find existing labels and identify suitable replacements. It is
marked as internal and for development purposes.

The CLI command "language:domain:list" has also been tagged
as internal and moved to EXT:lowlevel.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Garvin Hicking +1
  • Verified V +2 Done
    • Benni Mack +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 10

Review log 3241

Show 1116 earlier messages
  1. Lina Wolf uploaded patch set 1 11/13/25, 12:58

  2. Lina Wolf updated the commit message in patch set 2 11/13/25, 12:59

  3. Lina Wolf updated the commit message in patch set 3 11/13/25, 13:00

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

  5. core-ci voted on patch set 2 V +1 11/13/25, 13:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89496

  6. core-ci voted on patch set 3 V +1 11/13/25, 13:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89497

  7. Garvin Hicking commented on patch set 3 11/13/25, 13:22

    TranslationDomainSearchCommand.php:79

    ```suggestion 'Search for translation labels and label references by regular expression.', ```

    TranslationDomainSearchCommand.php:87

    ```suggestion 'Limit results to the first X results.', ```

    TranslationDomainSearchCommand.php:88

    I think the default should be unlimited

    TranslationDomainSearchCommand.php:95

    ```suggestion 'Crop labels to a maximum of x chars.', ```

    TranslationDomainSearchCommand.php:103

    ```suggestion 'Output a flat list.' ```

    TranslationDomainSearchCommand.php:110

    ```suggestion 'Output result as JSON (instead of table or SymfonyStyle messages).' ```

    TranslationDomainSearchCommand.php:129

    I think by default we could list all entries, or if restricted to an extension, all of that extension.

    TranslationDomainSearchCommand.php:215

    I get an error: ``` PHP Warning: Undefined array key "domain" in /var/www/html/typo3-core/typo3/sysext/core/Classes/Command/TranslationDomainSearchCommand.php line 215 ``` when running `typo3 language:domain:search --search=core` ?

    TranslationDomainSearchCommand.php:233

    good idea to pass that in here, nice!

    LocalizationFactory.php:269

    I am not sure this method fits the scope of this factory. Either make it a distinct service or be part of the command?

    LocalizationFactory.php:293

    Could be inlined in one `if $regex && (!preg_match...))` to reduce nesting

    LocalizationFactory.php:303

    I think this array structure is also very specific to the command output. Otherwise if we would use it for more core places we should have a DTO for that and a factory to initialize the DTO with named arguments. (I think an array structure would be fine for the Command scope)

    LocalizationFactory.php:318

    ```suggestion if ($labelData !== []) { ``` (Maybe even do an "early continue" instead of a nested if, to reduce nesting

    LocalizationFactory.php:326

    would "break 2" here allow to remove the lower break?

    Services.yaml:70

    Please register new commands directly inside the command, see: https://review.typo3.org/c/Packages/TYPO3.CMS/+/91566/5/typo3/sysext/backend/Classes/Command/DebugBackendModulesCommand.php#40 Also I think in line with that patch we should utilize "debug:language:search" or so, inside a "debug" scope?

    Feature-107840-AddCLICommandToSearchTranslationLabelsByStringOrRegex.rst:48

    How about also searching by "identifier" so I can search for "*.module.*" for example?
  8. Lina Wolf commented on patch set 3 11/13/25, 13:30

    TranslationDomainSearchCommand.php:79 Reply

    Fix applied.

    TranslationDomainSearchCommand.php:87 Reply

    Fix applied.

    TranslationDomainSearchCommand.php:95 Reply

    Fix applied.

    TranslationDomainSearchCommand.php:103 Reply

    Fix applied.

    TranslationDomainSearchCommand.php:110 Reply

    Fix applied.

    LocalizationFactory.php:318 Reply

    Fix applied.
  9. Lina Wolf commented on patch set 3 11/13/25, 13:40

    TranslationDomainSearchCommand.php:88 Reply

    I want to prevent ppl from accidently showing to many results and cluttering the console.

    TranslationDomainSearchCommand.php:129 Reply

    I want to prevent showing to many labels

    LocalizationFactory.php:269 Reply

    The method can also be used to search for labels in the backend later on or be called by third party extensions. Commands should contain no logic but the IO, really so that all logic can be reused

    Services.yaml:70 Reply

    As far as I know it is not yet able to exclude a command from the scheduler using the attribute: https://forge.typo3.org/issues/107151 As it does not make sense to have this command called via the scheduler I decided to register it in the Services.yaml just like the language:domain:list to which it is sister.
  10. Lina Wolf commented on patch set 4 V +1 11/13/25, 13:41

    Published edit on patch set 3.
  11. Garvin Hicking commented on patch set 4 11/13/25, 13:44

    TranslationDomainSearchCommand.php:88 Reply

    Acknowledged

    TranslationDomainSearchCommand.php:129 Reply

    It would be very helpful for me to see all of a scope, I think that would be useful. If I don't want to see too many labels, I can filter. If I explicitly want everything, I can't. But it would be a usecase for me. Especially with JSON export, which IMO should have an unlimited/unfiltered option.

    LocalizationFactory.php:269 Reply

    OK, but I think we need a distinct service for this then. Could also be moved from the command once such a backend GUI is created. For now it would IMO clutter this service.

    Services.yaml:70 Reply

    Why not schedule this command? If you want to use it as a check when new labels come in. I think it will not hurt to have it schedulable.
  12. Lina Wolf commented on patch set 4 11/13/25, 13:51

    Services.yaml:70 Reply

    Because it is writing to the console only, so you cannot use it in a scheduler command
  13. core-ci voted on patch set 4 V +1 11/13/25, 13:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89505

  14. Lina Wolf uploaded patch set 5 V +1 11/13/25, 14:27

  15. Lina Wolf commented on patch set 5 11/13/25, 14:28

    TranslationDomainSearchCommand.php:129 Reply

    Done

    TranslationDomainSearchCommand.php:215 Reply

    Done

    LocalizationFactory.php:269 Reply

    Done

    LocalizationFactory.php:293 Reply

    Done

    LocalizationFactory.php:303 Reply

    Done

    LocalizationFactory.php:326 Reply

    Done
  16. core-ci voted on patch set 5 V -1 11/13/25, 14:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89520

  1. Lina Wolf uploaded patch set 6 V -1 11/13/25, 15:01

  2. Lina Wolf commented on patch set 6 11/13/25, 15:02

    Feature-107840-AddCLICommandToSearchTranslationLabelsByStringOrRegex.rst:48 Reply

    Done
  3. core-ci voted on patch set 6 V -1 11/13/25, 15:14 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89531

  4. Garvin Hicking commented on patch set 6 11/13/25, 17:04

    Awesome, thanks for the reworks - two minor things then I'm good with this! :-)

    DomainSearchResult.php:4

    needs declare strict_types and TYPO3 copyright header (also in the other files)

    LabelFinder.php:23

    could be final, and "private TranslationDomainMapper"

    Services.yaml:70 Reply

    Understood. If we choose implement the NonSchedulableInterface, we could apply that here as a follow-up.
  5. Lina Wolf uploaded patch set 7 V -1 11/13/25, 21:15

  6. core-ci voted on patch set 7 V +1 11/13/25, 21:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89592

  7. Lina Wolf commented on patch set 7 11/13/25, 21:23

    DomainSearchResult.php:4 Reply

    Done

    LabelFinder.php:23 Reply

    Done
  8. Garvin Hicking voted on patch set 7 CR +1 V +1 11/14/25, 18:25

  9. Garvin Hicking commented on patch set 7 CR 0 V 0 11/17/25, 13:53

    Lina, would you agree on making this internal for now? Move to the debug: namespace like the other twos.Declare the PHP Classes internal. Remove feature rst, make the docs internal to the help output of the command. It's still "wip" so we could make it public once its more stable. For now it would be to big of a burden having it public.
  10. Lina Wolf commented on patch set 7 11/18/25, 14:33

    Reply

    I thought this was a feature that we wanted to have. Why would it be WIP now? Why a liability?
  11. Garvin Hicking commented on patch set 7 11/18/25, 14:37

    Reply

    Not WIP. Just s/FEATURE/TASK/ et al. This should not become public API (for now), but is there "for us core developers". Thus we need to label it a TASK, and not have a feature RST, and have the backend CLI commands set as "debug:" to indicate this, like the other two ViewHelpers. If you could do this, I would vote to merge this.
  12. Lina Wolf commented on patch set 7 11/18/25, 14:39

    Reply

    Why do you want to make this internal. It can be useful for projects as well?
  13. Lina Wolf commented on patch set 7 11/18/25, 14:42

    Reply

    The whole idea of this command is to make migration for PPL out there the migration easier with all the labels we are renaming, XLIFF files we are consolidating or moving. The idea is not to have some internal tool.
  14. Benni Mack commented on patch set 7 11/18/25, 14:53

    Reply

    I think the main idea is that if we label it as internal, we can still modify the API (PHP code), as people who migrate. Thinking about this more, should we move these commands into EXT:lowlevel, to give this extension some more reason to exist?
  15. Lina Wolf commented on patch set 7 11/18/25, 15:02

    Reply

    "internal" tells ppl: do not use this, do not rely on this. And that is not the purpose of this PR. When I write the docs about the label migration I want to tell ppl: Ok, this might seem confusing, but hey! there is a command out there to help you. These preliminary internals tend to stay around long time and hinder usage. Internal should be limited to things that absolutely have to be internal.
  16. Benni Mack commented on patch set 7 11/18/25, 15:17

    Reply

    Internal means: This is not covered by the TYPO3 Core backwards-compatibility promise. We've covered this when we introduced the internal property consistently and also wrote a blog post about it back then: https://typo3.org/article/typo3-deprecation-policy#c11597 That came because the code was mixed between "@api" and "@internal" and we wanted clarify what is API what isn't. If we would put a "don't use" on it, we could remove all internal code, because we'd tell "Don't use it". Don't use it != Don't rely on it. People shouldn't rely on the PHP code being like that.
  17. Lina Wolf commented on patch set 7 11/18/25, 15:56

    Reply

    Ok, @garvin@hick.ing if you feel it should go into debug: and not be treated as a feature, please feel free to make the adjustments you think are right. In that case I’ll step back from it, since it no longer aligns with what I intended to contribute. All good from my side, no hard feelings.
  18. Garvin Hicking commented on patch set 7 11/18/25, 17:08

    Reply

    I will do that (likely also move the ither two debug commands there), thanks. I still think this can readily be used, but we need to seal this off not being API and closed off for refactoring. The command itself can be used. but we might drop it next major version. If it's not internal we are not free to improve on it easily.
  19. Garvin Hicking uploaded patch set 8 V +1 11/18/25, 17:48

  20. Garvin Hicking updated the commit message in patch set 9 11/18/25, 17:49

  21. core-ci voted on patch set 8 V +1 11/18/25, 17:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/90066

  22. core-ci voted on patch set 9 V +1 11/18/25, 17:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/90067

  23. Garvin Hicking voted on patch set 9 CR +1 V +1 11/18/25, 18:10

  24. Benni Mack voted on patch set 9 CR +2 V +2 11/18/25, 18:12

  25. Benni Mack merged patch set 10 11/18/25, 18:12