Localize url in menu

Created on 5 June 2017, almost 8 years ago
Updated 7 February 2023, about 2 years ago

Hi,

I'm loading a menu programmatically and building a renderable array then to display it.

Here's how:

    $menu_tree = \Drupal::menuTree();

    // Build the typical default set of menu tree parameters.
    $parameters = $menu_tree->getCurrentRouteMenuTreeParameters($menu_name);
    // Load the tree based on this set of parameters.
    $tree = $menu_tree->load($menu_name, $parameters);
    // Transform the tree using the manipulators you want.
    $manipulators = array(
      // Only show links that are accessible for the current user.
      array('callable' => 'menu.default_tree_manipulators:checkAccess'),
      // Use the default sorting of menu links.
      array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
    );
    $tree = $menu_tree->transform($tree, $manipulators);

    // Finally, build a renderable array from the transformed tree.
    return $menu_tree->build($tree);

The issue is that on a multilingual website, only the links title are being translated and not the url. The menu link content is well configured as I can have a different value for the url for each language.

A patch is coming up.

πŸ› Bug report
Status

Postponed: needs info

Version

10.1 ✨

Component
Menu link contentΒ  β†’

Last updated 3 days ago

Created by

πŸ‡«πŸ‡·France garnett2125

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    @Sebastien M. could you confirm this behavior on D10/D9?

  • Status changed to Closed: outdated 8 days ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Since there hasn't been a follow up going to close out, but if still a valid bug in D11 please re-open.

Production build 0.71.5 2024