When the multilingual option of a menu is set to 'Translate and Localize', links have a language attribute. The menu_link_get_preferred function however, does not take into account the language. Instead, it returns the first matching link of the last menu, which is often a different language.

If e.g. breadcrumbs are build based on this (this is where I noticed this), the breadcrumbs in all site languages will be shown in whichever language link is found with the algorithm above. The proposed patch changes this to prefer links in the current language, while in all other cases (i.e. if no languages or no 'other' languages are available) maintaining the current behavior.

Comments

arnt created an issue. See original summary.

arnt’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, breadcrumb_translation.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, breadcrumb_translation.patch, failed testing.

robertom’s picture

Hi, sorry for my bad english.

I have same problem, my menu_links table have 2 entry with same 'link_path' and 'router_path' for the same menu_name, but with a different language (en and fr).

menu_link_get_preferred always prefer entry with max(mlid).

I would attach a patch that solve for now my problem

robertom’s picture

Version: 7.39 » 7.x-dev
robertom’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
robertom’s picture

new patch for testbot

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.