Issue Bug Closed

#110236Using TranslatorInterface via dependency injection failed

Tee Ohh 07/20/26, 10:29 updated 07/21/26, 11:17

Description

I tryed to use the new feature #89334 (Add generic TranslatorInterface) but the example failed to work. I think there is a conceptual error. The LanguageService implements the new TranslatorInterface but the LanguageService must be created over the LanguageServiceFactory. Using the TranslatorInterface via dependency injection failed with the error

Symfony\Component\DependencyInjection\Exception\RuntimeException
Cannot autowire service “Verdor\MyPackage\Controller\MyController”: argument “$translator” of method “__construct()” references interface “TYPO3\CMS\Core\Localization\TranslatorInterface” but no such service exists. Did you create an instantiable class that implements this interface?”

Can you please clarify how this new feature should work?

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 1

  1. Garvin Hicking commented and changed category status New Closed <span data-processor="relativetime" data-value="2026-07-21T11:17:45+00:00" > 07/21/26, 11:17 </span>

    Hi!

    The feature document about this only mentions that TranslatorInterface is meant for type-hinting. So this is more a forward-compatible way, and not meant as “use DI for this”. This will, however, be very likely addressed in future versions.

    Currently, the default implementation of the TranslatorInterface (LanguageService) is not fully registered as a service provide / DI target.

    Having the interface though allows implementations to use their own service, as long as they pass around their interface translations.

    I hope that helps – so for now this isn’t a conceptual error, but rather “more features yet to come”. I hope with this explanation it’s ok to close the issue, otherwise please report back. :)