Drupal is a registered trademark of Dries Buytaert
Release: Leaflet 10.4.11 Minor update available for module leaflet (10.4.11). Release: Session Inspector 1.0.8 Minor update available for module session_inspector (1.0.8). Release: Migrate QA 2.0.4 Minor update available for module migrate_qa (2.0.4). Release: CKEditor Description List 3.0.0 Major update available for module ckeditor_descriptionlist (3.0.0). Release: FlowDrop 2.4.0 Minor update available for module flowdrop (2.4.0). Release: JWT Token Refresh 1.0.4 Minor update available for module jwt_token_refresh (1.0.4). Release: ConReg 1.0.0-beta1 First beta version released for module conreg (1.0.0-beta1). Release: AI Image Studio 1.0.0-beta8 New beta version released for module ai_image_studio (1.0.0-beta8). Usage Milestone: Role Theme Switcher Module role_theme_switcher crossed 1,000 active installs. Module Revived: Decoupled Router 2.0.7 Module decoupled_router updated after 11 months of inactivity (2.0.7).

Language Switcher Menu

808 sites Security covered
View on drupal.org

This module adds language switcher links, usually found in blocks, as menu items within your chosen Drupal menus. It is useful for integrating language navigation directly into your site's main menu structure.

Synopsis

The Language Switcher Menu module allows you to add the language switch links generated by the language module of Drupal Core as menu link items to one of your menus.

Use case

You would like to replace the Language Switcher Block that displays the links to view a page of your web site in another language with menu links in one of your menus.

Requirements

This module depends on the language and menu modules provided by Drupal Core.

Usage

  1. Review the permissions provided by the module. There is one permission to configure the module and (for now, see below) a permission to view language switcher menu links added by the module.
  2. Go to the configuration page of the module at Configuration > Regional and language > Language Switcher Menu.
  3. Select the language type you want to use to generate the links.
  4. Select a parent menu item. The language switcher links will be added below that menu item. As usual, you may select the name of a menu to add the links to the root level. You may select the Disabled option, if you want to (temporarily) disable the functionality of the module without uninstalling it.
  5. Select the weight of the first language switcher link to be added to the menu. For any additional language switcher links, the weight will be increased by 1.
  6. Click Save configuration.

Important note

Due to an issue in Drupal Core, language switcher links added to the menu would always be invisible. As a workaround, the module won't just add the language switcher links to the menu, but will also override Drupal's Menu Tree Manipulator service and grant access to any language switcher menu links added by the module to any user that has the permission to View Language Switcher Menu links. Once that issue has been fixed, the workaround and the permission will be removed. As a result of that workaround, the module might be incompatible with other modules that also override the Menu Tree Manipulator service.

FAQ

How can I alter the generated links?

You may implement hook_language_switch_links_alter() provided by Drupal Core in a custom module or use any other contributed module that implements that hook to alter the language switcher links. Alternatively, you may override menu.html.twig in your custom theme (see below) or implement a preprocess function.

How do I target the links in Twig templates?

You can check, if the id of the menu link starts with language_switcher_menu.language_switcher_link:. item.original_link.class or item.original_link.provider are also a good candidates to check, whether the links have been generated by Language Switcher Menu module. If needed, you can get the language object using item.original_link.getOptions()['language']. Below is an example of a custom menu.html.twig template that uses custom markup for language switcher links:

{#
/**
 * @file
 * Theme override to display a menu.
 *
 * Available variables:
 * - menu_name: The machine name of the menu.
 * - items: A nested list of menu items. Each menu item contains:
 *   - attributes: HTML attributes for the menu item.
 *   - below: The menu item child items.
 *   - title: The menu link title.
 *   - url: The menu link url, instance of \Drupal\Core\Url
 *   - localized_options: Menu link localized options.
 *   - is_expanded: TRUE if the link has visible children within the current
 *     menu tree.
 *   - is_collapsed: TRUE if the link has children within the current menu tree
 *     that are not currently visible.
 *   - in_active_trail: TRUE if the link is in the active trail.
 */
 #}
 {% import _self as menus %}

{#
  We call a macro which calls itself to render the full tree.
  @see http://twig.sensiolabs.org/doc/tags/macro.html
  #}
  {{ menus.menu_links(items, attributes, 0) }}

  {% macro menu_links(items, attributes, menu_level) %}
    {% import _self as menus %}
    {% if items %}
      {% if menu_level == 0 %}
        <ul{{ attributes.addClass('menu', 'menu--level-0') }}>
      {% else %}
        <ul class="menu menu--level-{{ menu_level}}">
        {% endif %}
        {% for id, item in items %}
          {% set classes = [
            'menu__item',
            item.is_expanded ? 'has-children',
            item.in_active_trail ? 'in-active-trail',
          ] %}
          <li{{ item.attributes.addClass(classes) }}>
            {% if id starts with 'language_switcher_menu.language_switcher_link:' %}
              {% set language = item.original_link.getOptions()['language'] %}
              <a href="{{ item.url }}" lang="{{ language.getId() }}" class="language-switcher-link"><abbr title="{{ item.title }}">{{ language.getId() }}</abbr></a>
            {% else %}
              {{ link(item.title, item.url, { 'class':['menu__link']}) }}
            {% endif %}
            {% if item.below %}
              {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
            {% endif %}
          </li>
        {% endfor %}
      </ul>
    {% endif %}
{% endmacro %}

Credits

Current maintainers:

The development of this project has been partly sponsored by werk21 GmbH.

Activity

Tracked releases
1
Tracked since
Jul 2026
Latest release
1 month ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Release date
1.0.0-beta7 Pre-release Jul 3, 2026