The loadLanguageFile hook is triggered when a language file is loaded. It passes the file name and the language as arguments and does not expect a return value.


  1. string $name

    The language file to be loaded (e.g. tl_content), without file extension.

  2. string $currentLanguage

    The language, usually the same as $GLOBALS['TL_LANGUAGE'] but the call to \Contao\System::loadLanguageFile accepts a language parameter.

  3. string $cacheKey

    The internal cache key.


// src/EventListener/LoadLanguageFileListener.php
namespace App\EventListener;

use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;

class LoadLanguageFileListener
    public function __invoke(string $name, string $currentLanguage, string $cacheKey): void
        // Do something …