getLanguages

The getLanguages hook allows to modify the system’s list of languages.

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

  1. array $compiledLanguages

    The 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.

  2. array $languages

    The list of languages from the system config file languages.php with english language names.

  3. array $langsNative

    The list of languages with native language names (also read from from the system config file languages.php).

  4. bool $installedOnly

    Indicates 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\ServiceAnnotation\Hook;

/**
 * @Hook("getLanguages")
 */
class GetLanguagesListener
{
    public function __invoke(array &$compiledLanguages, array $languages, array $langsNative, bool $installedOnly): void
    {
        // Make your changes to $compiledLanguages
    }
}

References