getLanguages
Details
This page shows version 4.x. The current version can be found here.
The getLanguages hook allows to modify the system’s list of languages.
Note
Using the getLanguages hook has been deprecated and will no longer work in Contao 5.0. Decorate the Contao\CoreBundle\Intl\Locales
service instead.
Parameters
array
$compiledLanguagesThe array containing the languages as filled by
\Contao\System::getLanguages()according to the system configuration. This parameter has to be passed by reference if you want your changes to become effective.array
$languagesThe list of languages from the system config file
languages.phpwith english language names.array
$langsNativeThe list of languages with native language names (also read from from the system config file
languages.php).bool
$installedOnlyIndicates whether only languages installed in the back end should be considered in the result.
Example
// src/EventListener/GetLanguagesListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('getLanguages')]
class GetLanguagesListener
{
public function __invoke(array &$compiledLanguages, array $languages, array $langsNative, bool $installedOnly): void
{
// Make your changes to $compiledLanguages
}
}