#StackBounty: #8 #i18n-l10n #navigation How can I have the language-specific 'enabled' Boolean of menu items being respected?

Bounty: 50

I’m trying to translate the ‘enabled’ field of menu items in Drupal 8. So far I have written this code in MYMODULE.module file:

function MYMODULE_entity_base_field_info_alter(&$fields, DrupalCoreEntityEntityTypeInterface $entity_type) {
  if ($entity_type->id() == 'menu_link_content' && !empty($fields['enabled'])) {
  return $fields;

This works fine and I am able to set the enabled field differently for different languages. eg: for the same menu item, I can check the ‘enabled’ field for English, but uncheck the ‘enabled’ field for French.

But it does not work as expected. It hides the menu item for all languages. Should I use hook_preprocess() or hook_preprocess_menu() or some other hook for the menu item to show/hide based on ‘enabled’ field in different languages? Can someone give me some hints on this?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.