0

I've a strange problem. I've a multilingual site with many menus configures as "Translate and localize".

Everything works, every menu link has his language, but ONLY when I go to a node/%nid/edit page the system prints all links, on both language (on every language)

This behaviour there is on every theme. I've i18n modules enabled.

What's wrong?

0

I'm not sure i fully understand the question, but please take a look to this post:

https://drupal.stackexchange.com/a/96963/30465

It seems related to your question.

I this it will be related to the language configuration fallback (since there is no language suffix inlcuded)

You could for example try

http://www.example.com/en/node/%nid/edit

if that works correctly (and only shows the engish menu links), you know that it will be a problem with language fallback.

Hope this helps, feel free to let me now if you need more!! :)

  • My links are not "language neutral", the problem is this. And that this bug appears only on one page.. – arrubiu Mar 9 '15 at 15:24
  • 1
    Dear arribu, i have a multilingual setup on my sandbox at home, will take a look there and report back in a couple hours – Guardian Mar 9 '15 at 15:31
  • Guardian, I've posted the solution.. I think it's absurd -.- – arrubiu Mar 9 '15 at 17:17
  • Arrubio, thanks for posting and getting back to me on this as well. It is very weird indeed...This needs some looking into imho – Guardian Mar 10 '15 at 18:07
0

The problem is the function _i18n_menu_link_process of i18n_module.

<?php    
    /**
     * Check whether this link is to be processed by i18n_menu and start processing.
     */
    function _i18n_menu_link_process(&$link) {
      // Only visible links that have a language property and haven't been processed
      // before. We also check that they belong to a menu with language options.
      if (empty($link['i18n_menu']) && !empty($link['language']) && !empty($link['access']) && empty($link['hidden']) && i18n_menu_mode($link['menu_name'])) {
        // Mark so it won't be processed twice.
        $link['i18n_menu'] = TRUE;
        // Skip if administering this menu or this menu item.
        if (arg(0) == 'admin' && arg(1) == 'structure' && arg(2) == 'menu') {
          if (arg(3) == 'manage' && $link['menu_name'] == arg(4)) {
            return FALSE;
          }
          elseif (arg(3) == 'item' && arg(4) == $link['mlid']) {
            return FALSE;
          }
        }
        // Skip if administering this menu item through the node edit form.
        elseif (arg(0) == 'node' && arg(2) == 'edit') {
          return FALSE;
        }
        return TRUE;
      }
      else {
        return FALSE;
      }
    }
?>

This function returns TRUE or FALSE when checking if a menu link should be "hidden" (and so not displayed). At the end this value "hidden" is TRUE for link of a language different from current user language.

This function EXCLUDES this "hidden => TRUE" value when the request page is node/%nid/edit, and I don't understand way.

So there are two solutions:

  • apply a patch to this function
  • declare in a custom module the hook_translated_menu_link_alter, force this hook to run AFTER i18n_menu and apply my "logic"

And, obviously, ask on drupal.org the reason of this behaviour.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.