Creating multilingual mega menus with WPML

With Max Mega Menu and WPML you can create multilingual Mega Menus for your WordPress site.

In this example we will assume the site and menu have been set up already, and WPML has subsequently been installed to add support for another language. Our primary language is English and the language we’re adding is French.

Prerequisites

Under WPML > Languages, make sure “Adjust IDs for multilingual functionality” is enabled (in the “Make themes work multilingual” section).

WPML Adjust IDs for multilingual functionality option

Step 1: The English menu

In this step we assume you’ve already set up a menu for your primary language (English) and enabled Max Mega Menu for its menu location.

Go to Appearance > Menus and select your English menu. Ensure the “Language” setting is set to “English” and that the menu is assigned to a menu location. Then click the “+ French” link next to “Translations” to create the French version of the menu.

English menu with Language set to English, the Header location selected and the French translation link

Step 2: Create the French menu

Give the new menu an appropriate name. WPML automatically sets the “Language” to French and the “Translation of” setting to your English menu.

Assign the menu to the same menu location as your English menu, then click “Create Menu”.

Creating the French translation of the menu

Step 3: Set up the French menu

We now have 2 menus (one English, one French) which are linked together. Add your French menu items and configure the Mega Menu settings for each item as required.

French menu linked to the English menu as its translation

End Result

The English menu will automatically be swapped for the French menu when the site is viewed in French. Max Mega Menu is enabled for both menus, and each menu can be configured independently.

English menu on the front end

French menu on the front end

Note: The menu location (and therefore the menu theme and location settings) is shared across all languages. Max Mega Menu automatically generates a separate CSS file for each language.

Translating the mobile toggle block text

The same menu theme is used for all languages. As the text for the mobile toggle blocks is defined in the menu theme, it will appear the same for all of your languages. We can use a shortcode to change the text depending on the current language.

Step 1: Add the following code to your theme’s functions.php file (or use a code snippets plugin):

Step 2: Go to Mega Menu > Menu Themes > Mobile Menu. In the Toggle Bar Designer, edit the toggle block and use the shortcode to display different text for each language:

Important: Do not use quotes around the language code (use lang=fr, not lang=”fr”).

Language specific shortcodes in the Menu Toggle block text

Translating the Logo mobile toggle block URL

Requires Max Mega Menu Pro.

The same shortcode can be used in the URL field of the Logo toggle block. For example:

See also: How to add a WPML Language selector to the mobile toggle bar.