Skip to content

fix(MenuLinkUrl): Handle translation of URls#1421

Closed
joaogarin wants to merge 1 commit into
8.x-4.xfrom
fix_url_translation
Closed

fix(MenuLinkUrl): Handle translation of URls#1421
joaogarin wants to merge 1 commit into
8.x-4.xfrom
fix_url_translation

Conversation

@joaogarin
Copy link
Copy Markdown
Member

This PR is somewhat related to #809 which adds multilingual support for menu links. That works well, however in our case we are passing the language parameter to the menu, and that seems to not get carried away to the URL.

The label is translated fine but the URL itself (which in our case is not translated in the menu item its just the original URL) is not really picked up..the link is to a node so it should be possible to return the translated URL

Our resolvers look like this :

Getting the menu :

// Menu query.
$registry->addFieldResolver('Query', 'menu',
  $builder->produce('menu_load', [
    'id' => $builder->fromArgument('name'),
    'access' => $builder->fromValue(FALSE),
    'language' => $builder->fromArgument('language'),
  ])
);

getting the menu items :

// Menu items.
$registry->addFieldResolver('Menu', 'items',
  $builder->produce('menu_links', [
    'menu' => $builder->fromParent(),
  ])
);

Item URL :

// Menu url.
$registry->addFieldResolver('MenuItem', 'url',
  $builder->produce('menu_link_url', [
    'link' => $builder->produce('menu_tree_link', [
      'element' => $builder->fromParent(),
    ]),
  ])
);

@github-actions
Copy link
Copy Markdown

Please open issues and pull requests on drupal.org: https://www.drupal.org/project/issues/graphql
Auto-closing this pull request.

@github-actions github-actions Bot closed this Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant