Problem/Motivation
We have a very nice translation system in place that is based on translating fields on entities. For many cases this work very well, but in some cases we need to special care. One of these places are menu items. Right now, when you display menu items, fx with the menu block from core, all menu items are displayed regardless of it being translated or not. This is bad for a few reasons.
- Having a menu with mixed languages is often not desired for site builders / end users
- Different menu blocks can have different requierments (e.g. filter main menu by current language, but not the footer menu)
- It's not possible to hide menu items on certain languages (where they might not be relevant)
Steps to reproduce:
- Install Drupal with several language and enable menu translation
- Display the main menu with the core menu block
- Create some pages with links in the main menu
- Visit a page with the menu with a UI missing translations for menu items
Actual result:
All the menu items are displayed in the menu, untranslated in the original (or another) language.
Expected result:
Only the translated menu items are displayed in the menu.
Proposed resolution
Add a new API to allow manipulating menu link trees: this has been requested in #3091246: Allow MenuLinkTree manipulators to be altered and #2854013: Allow SystemMenuBlock tree manipulators to be altered too.
Add first usage of this API to Custom Menu Links module to add a new setting that allows limiting the menu block to display menu items for the current language, or those without a specific language (not specified, not applicable).
Remaining tasks
Decide how handle different types of menu items (from code. *.links.menu.yml, from views, from menu link entity). This could potentially be a follow-up issue.
User interface changes
TBD.
API changes
None.
Data model changes
None.