Review main Abandoned

88011[FEATURE] Introduce consolidated `LanguageService->translate()`

Andreas Kienast CR 0 V 0 Normal +135 −0 updated 03/25/25, 09:01

Commit message

The `LanguageService` class now has a new method `translate()`, aiming
to simplify working with locallang files.

Accepted arguments:

* `$labelReference` (`string`)
* `$data` (`array<string, scalar|\Stringable>`)
* `$fallback` (`string`)

The method accepts, similar to `sL()`, a label reference but without the
`LLL:` prefix. Also, it is possible to add arguments for data
interpolation.

Language label interpolation allows to use named placeholders within language
labels. Developers don't have to remember the order of placeholders when using
`sprintf()` (or alike) which may create semantically wrong labels.

Also, non-technical people, e.g. translators benefit from a better context.

Interpolation can also be implemented in programming languages where string
formatting is not available (e.g. JavaScript).

An optional fallback value can be passed which is applied in case the requested
language label does not exist.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 4

Review log 710

  1. Andreas Kienast uploaded patch set 1 02/04/25, 11:32

  2. Andreas Kienast commented on patch set 1 02/04/25, 11:37

    LanguageService.php:252 Unresolved

    Method name is open for discussion.
  3. Andreas Kienast voted on patch set 1 CR -2 02/04/25, 11:38

  4. core-ci voted on patch set 1 V -1 02/04/25, 11:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73486

  5. Andreas Kienast uploaded patch set 2 V -1 02/04/25, 11:39

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  6. Andreas Kienast marked it work in progress 02/04/25, 11:39

  7. core-ci voted on patch set 2 V +1 02/04/25, 11:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73487

  8. Andreas Kienast uploaded patch set 3 V +1 02/05/25, 07:27

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  9. core-ci voted on patch set 3 V +1 02/05/25, 07:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73555

  10. Andreas Kienast abandoned the change 03/25/25, 09:01