How do I filter a menu to only show menu items translated into current language? In my Drupal 8 project I have a menu containing menu items in english. Some of the items have a german translation. How do I filter the menu to only show the german items when viewing the site in german? 

I'm currently using MenuLinkTree to fetch my menu and I have created my own MenuLinkTreeManipulator transform where I try to filter out MenuLinkContent items that does not have a translation in the current language. But the method for getting an entity from a MenuLinkContent object is protected, so I cannot access the language property of the underlying entity!

Is there some other way of finding out the language of a MenuLinkContent object? Or another way of filtering a menu by current language? 

Edit:

Here is the method I'm currently using (as a transform) when getting the menu via the MenuLinkTree service:

public function currentLanguage($tree) {
  $lang = \Drupal::languageManager()-&gt;getCurrentLanguage()-&gt;getId();

  return array_filter($tree, function($item) use($lang) {
    return $item-&gt;link-&gt;getEntity()-&gt;language()-&gt;getId() === $lang;
  });
}


$item-&gt;link above is an instance of \Drupal\menu_link_content\Plugin\Menu\MenuLinkContent. The above code does not work since $item-&gt;link-&gt;getEntity() is a protected method. If make it public the code above works. I see no way of accessing the underlying entity here without hacking core. Is it possible in any way? Is it possible to "swap" out this class for my own implementation in a custom module?
I managed to hide non translated menu items with the following code:

use Drupal\Core\Menu\MenuLinkInterface;
use Drupal\menu_link_content\Plugin\Menu\MenuLinkContent;

/**
* Implements hook_preprocess_menu().
*/
function MY_MODULE_preprocess_menu(&amp;$variables) {
  if ($variables['menu_name'] == 'main') {
   $language = Drupal::languageManager()-&gt;getCurrentLanguage()-&gt;getId();

    foreach ($variables['items'] as $key =&gt; &amp;$item) {
      $menuLinkEntity = MY_MODULE_load_link_entity_by_link($item['original_link']);

      if ($menuLinkEntity != NULL) {
        $languages = $menuLinkEntity-&gt;getTranslationLanguages();
        // Remove links which is not translated to current language.
        if (!array_key_exists($language, $languages)) {
          unset($variables['items'][$key]);
        }
      }
    }
  }
}

function MY_MODULE_load_link_entity_by_link(MenuLinkInterface $menuLinkContentPlugin) {
  $entity = NULL;

  if ($menuLinkContentPlugin instanceof MenuLinkContent) {
    list($entity_type, $uuid) = explode(':', $menuLinkContentPlugin-&gt;getPluginId(), 2);
    $entity = \Drupal::entityManager()-&gt;loadEntityByUuid($entity_type, $uuid);
  }
  return $entity;
}


There is probably a better way but this worked for me.
Got the inspiration from here: http://www.agoradesign.at/blog/add-custom-menu-item-attributes-drupal-8