ModifyLanguagePacksEvent

New in version 12.2

The PSR-14 event \TYPO3\CMS\Install\Service\Event\ModifyLanguagePacksEvent allows to ignore extensions or individual language packs for extensions when downloading language packs.

The options of the language:update command can be used to further restrict the download (ignore additional extensions or download only certain languages), but not to ignore decisions made by the event.

Example

EXT:my_extension/Classes/Install/EventListener/MyEventListener.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Install\EventListener;

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Install\Service\Event\ModifyLanguagePacksEvent;

#[AsEventListener(
    identifier: 'my-extension/modify-language-packs',
)]
final readonly class MyEventListener
{
    public function __invoke(ModifyLanguagePacksEvent $event): void
    {
        $extensions = $event->getExtensions();
        foreach ($extensions as $key => $extension) {
            // Do not download language packs from Core extensions
            if ($extension['type'] === 'typo3-cms-framework') {
                $event->removeExtension($key);
            }
        }

        // Remove German language pack from EXT:styleguide
        $event->removeIsoFromExtension('de', 'styleguide');
    }
}
Copied!

New in version 13.0

The PHP attribute \TYPO3\CMS\Core\Attribute\AsEventListener has been introduced to tag a PHP class as an event listener. Alternatively, or if you need to be compatible with older TYPO3 versions, you can also register an event listener via the Configuration/Services.yaml file. Switch to an older version of this page for an example or have a look at the section Implementing an event listener in your extension.

API

class \TYPO3\CMS\Install\Service\Event\ ModifyLanguagePacksEvent

Event to modify the language pack array

getExtensions ( )
returntype

array

removeExtension ( string $extension)
param string $extension

the extension

removeIsoFromExtension ( string $iso, string $extension)
param string $iso

the iso

param string $extension

the extension