loadLanguageFile
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.
Parameters
string
$name
The language file to be loaded (e.g.
tl_content
), without file extension.string
$currentLanguage
The language, usually the same as
$GLOBALS['TL_LANGUAGE']
but the call to\Contao\System::loadLanguageFile
accepts a language parameter.string
$cacheKey
The internal cache key.
Example
// src/EventListener/LoadLanguageFileListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('loadLanguageFile')]
class LoadLanguageFileListener
{
public function __invoke(string $name, string $currentLanguage, string $cacheKey): void
{
// Do something …
}
}