BeforeLabelResourceResolvedEvent 

New in version 14.0

The PSR-14 event \TYPO3\CMS\Core\Mail\Event\BeforeLabelResourceResolvedEvent is dispatched before the message is sent by the mailer and can be used to manipulate \Symfony\Component\Mime\RawMessage and the \Symfony\Component\Mailer\Envelope. Usually a \Symfony\Component\Mime\Email or \TYPO3\CMS\Core\Mail\FluidEmail instance is given as RawMessage. Additionally, the mailer instance is given - depending on the implementation - usually \TYPO3\CMS\Core\Mail\Mailer . It contains the \Symfony\Component\Mailer\Transport object, which can be retrieved using the getTransport() method.

The \TYPO3\CMS\Core\Localization\Event\BeforeLabelResourceResolvedEvent PSR-14 event is dispatched during translation domain resolution, directly after a domain name has been generated from a language file path. It allows extensions to customize or adjust the generated domain name before the mapping is finalized.

This event is useful if your project or extension requires a different naming scheme for domain identifiers or if you need to normalize file-to-domain mappings in a specific way.

The event provides access to the following public properties:

  • $fileName – The absolute path of the language file being processed
  • $extensionKey – The extension key the file belongs to
  • $domain – The generated domain name (modifiable)

Example: Map translation domain for my_extension.messages to a different file 

This example listener shortens generated domain names for a specific extension:

EXT:my_extension/Classes/EventListener/CustomTranslationDomainResolver.php
<?php

namespace MyVendor\MyExtension\EventListener;

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Localization\Event\BeforeLabelResourceResolvedEvent;

final readonly class CustomTranslationDomainResolver
{
    #[AsEventListener(identifier: 'my-extension/custom-domain-names')]
    public function __invoke(BeforeLabelResourceResolvedEvent $event): void
    {
        // Shorten domain names for specific extension
        if ($event->packageKey !== 'my_extension') {
            return;
        }

        $event->domains['my_extension.messages'] =
            'EXT:my_extension/Resources/Private/Language/my_messages.xlf';
    }
}
Copied!

API of the event BeforeLabelResourceResolvedEvent 

class BeforeLabelResourceResolvedEvent
Fully qualified name
\TYPO3\CMS\Core\Localization\Event\BeforeLabelResourceResolvedEvent

Event that is fired after a file name has been mapped to a translation domain for all files of a package.

E.g. "vendor/myext.messages" is mapped to "EXT:myext/Resources/Private/Language/locallang.xlf"

If you want this file to be a different location, e.g. for historical reasons, you can do this here.

public readonly packageKey
public domains