BeforeLabelResourceResolvedEvent
New in version 14.0
The PSR-14 event
\TYPO3\
is dispatched before the message is sent by the mailer and can be
used to manipulate
\Symfony\ and the
\Symfony\. Usually a
\Symfony\ or
\TYPO3\
instance is given as
Raw. Additionally, the mailer instance is
given - depending on the implementation - usually
\TYPO3\. It contains the
\Symfony\ object, which can be retrieved using
the
get method.
The
\TYPO3\
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:
$file– The absolute path of the language file being processedName $extension– The extension key the file belongs toKey $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:
<?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';
}
}
API of the event BeforeLabelResourceResolvedEvent
- class BeforeLabelResourceResolvedEvent
-
- Fully qualified name
-
\TYPO3\
CMS\ Core\ Localization\ Event\ Before Label Resource Resolved Event
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.