Hi There,

Currently I am injecting our English links into the menu with machine name "main". This is working well.

We are building a multilingual site -- English, Spanish and Chinese. The design recommendation from Gábor Hojtsy is to create one menu and block for each language as you can see here:

http://www.drupal8multilingual.org/hacks/drupal-8-multilingual-hack-1-bu...

I need to create three different menus -- one for each language. The block associated with the menu will be restricted so it will only show when a page of the associated language is requested. for example, when a Spanish page is shown, the Spanish Nav Menu will be shown as well.

How can I setup these menus so that Bootstrap will recognize each of them as a Nav menu?

Thanks!

Comments

Greg Sims created an issue. See original summary.

markhalliwell’s picture

Status: Active » Closed (works as designed)

Just assign the block(s) to the navigation (or navigation_collapsible) region. Anything past that really falls outside the scope of this project.

Greg Sims’s picture

Status: Closed (works as designed) » Active

I did not write this issue very well initially -- sorry.

The default main menu is unique because of: menu--main.html.twig. It appears in order to have the same features on three navbars we need to copy menu--main.html.twig three times, one for each of the language primary menus ids. It would be great to have one .twig that covers a set of menu ids (for example: main-en, main-es, main-zh). This would allow for one set of twig code that applies to this set of menus. Do you know if this is possible? Perhaps another approach would be better.

I appreciate your help! Greg

markhalliwell’s picture

Status: Active » Closed (works as designed)

There's two possible solutions:

  1. Extend menu--main-en.html.twig, menu--main-es.html.twig and menu--main-zh.html.twig from menu--main.html.twig.
  2. Use hook_theme_suggestions_alter().
kaido.toomingas’s picture

I had the same situation. What I did was.

Created all the different menus. Created files as Mark suggested and added only.
{% include 'menu--main.html.twig' %}