app/Module/ModuleThemeTrait.php
public function menuLanguages(): ?Menu
    {
        $menu = new Menu(I18N::translate('Language'), '#', 'menu-language');

        foreach (I18N::activeLocales() as $locale) {
            $language_tag = $locale->languageTag();
            $class        = 'menu-language-' . $language_tag . (WT_LOCALE === $language_tag ? ' active' : '');
            $menu->addSubmenu(new Menu($locale->endonym(), '#', $class, [
                'onclick'       => 'return false;',
                'data-language' => $language_tag,
            ]));
        }

        if (count($menu->getSubmenus()) > 1) {
            return $menu;
        }

        return null;
    }
public function menuLanguages(): ?Menu
    {
        $menu = new Menu(I18N::translate('Language'), '#', 'menu-language');

        foreach (I18N::activeLocales() as $locale) {
            $language_tag = $locale->languageTag();
            $class        = 'menu-language-' . $language_tag . (WT_LOCALE === $language_tag ? ' active' : '');
            $menu->addSubmenu(new Menu($locale->endonym(), '#', $class, [
                'onclick'       => 'return false;',
                'data-language' => $language_tag,
            ]));
        }

        if (count($menu->getSubmenus()) > 1) {
            return $menu;
        }

        return null;
    }
public function menuLanguages ( ) : ? Menu { $ menu = new Menu ( I18N :: translate ( 'Language' ) , '#' , 'menu-language' ) ; foreach ( I18N :: activeLocales ( ) as $ locale ) { $ language_tag = $ locale -> languageTag ( ) ; $ class = 'menu-language-' . $ language_tag . ( WT_LOCALE === $ language_tag ? ' active' : '' ) ; $ menu -> addSubmenu ( new Menu ( $ locale -> endonym ( ) , '#' , $ class , [ 'onclick' => 'return false;' , 'data-language' => $ language_tag , ] ) ) ; } if ( count ( $ menu -> getSubmenus ( ) ) > 1 ) { return $ menu ; } return null ; }
A menu to show a list of available languages.

@return Menu|null
A menu to show a list of available languages .