Apologies if there is another issue that covers this, but I was unable to find it.

Setup:

  • Drupal 7.17
  • Bartik 7.17
  • i18n 7x-1.8
  • Clean install

I am finding that when enabling i18n as per the HowTo: Basic Internationalization setup page, there are some issues around menu items.

Using main menu (Primary links) I have:

  • Enabled translation on the basic page content type
  • Enabled translation on the menu
  • Set a language on the page
  • Enabled path auto
  • Checked create menu link
  • Then translated the page
  • Checked create menu link on the translation

As expected I have 2 items in the menu, one for each language. Occasionally I am having issues with the default language item showing in both languages but, my main issue is when editing already translated nodes.

When you edit an already translated node, the menu item becomes "Disabled" and disappears from view... (see screenshot).

Really appreciate some help on this. I am hoping that I have missed a setting somewhere but so far it looks like a bug.

Thanks,

Ashley

Comments

ashleyhazle’s picture

So I have found the problem.

This is only occurring when you edit a node in a different language.

Example:

You are on http://example.com/en-gb/content/test-page-1 (node 1), you can edit this page without any issues, however! If you are on http://example.com/en-gb/node/2, the French version of the same page but viewed from the English URL, then when you edit this page (en-gb/node/2/edit) you don't have access to the French menu, thus the menu item is disabled.

If you edit the same page from the French url (fr/node/2/edit) then everything is fine and your menu item remains active.

This of course works in reverse too, editing the English version from the French URL.

It still seems to me to be something of a bug. We are looking at writing a small module to check the language of the user agains the language of the node, and redirect to accordingly, but would love to find a more rounded solution.

A

arnoldski’s picture

This piece of code works for the basic pages:

function form_alter(&$form, $form_state, $form_id)
{
    if(preg_match('/^.*_node_form$/', $form_id))
    {
	// check if the backend language is the same as the node language         
        global $language;
        if(isset($form['#node']) && $form['#node']->type == 'page' && $language->language != $form['#node']->language)
        {
            $node = $form['#node'];
            
            //Get the list of language objects
            $languages = language_list();
            
            //Get the object and set the global $language;
            $language = $languages[$node->language];            
            
            //Redirection            
            unset($_GET['destination']);            
            drupal_goto("node/{$node->nid}/edit", array('language' => $language));            
        }
    }
}
ykyuen’s picture

The #2 solution works like a charm. Thanks Arnoldski.

here is a modified version. it will set the destination on the url so the user will return to the original path.

function <module>_form_alter(&$form, $form_state, $form_id) {
  if(preg_match('/^.*_node_form$/', $form_id)) {
    // check if the backend language is the same as the node language
    global $language;
    if(isset($form['#node']) && $form['#node']->type == 'page' && $language->language != $form['#node']->language) {
      $node = $form['#node'];
      
      //Get the list of language objects
      $languages = language_list();
      
      //Get the object and set the global $language;
      $language = $languages[$node->language];
      
      //Redirection
      $destination = array('destination' => $_GET['destination']);
      unset($_GET['destination']);
      drupal_goto("node/{$node->nid}/edit", array('language' => $language, 'query' => $destination));
    }
  }
}

martins.bertins’s picture

Status: Active » Needs review
StatusFileSize
new780 bytes

Here's a patch I created.

martins.bertins’s picture

cdnsteve’s picture

I tried disabled_menu_items-1905268-3.patch but it didn't work.

For language neutral all menu items become disabled.
If you're in English the opposite language menu items are all disabled.

Reverting to 7.x-1.7 fixes the issue

monsoon’s picture

Hi I have similar issue.
cdnsteve can you please point me where can I get older version 7.x-1.7 of Internationalization?

or if I should use the code given above where should I put it?

Thanks,

cdnsteve’s picture

Sure!
If you have Drush installed:
drush dl i18n-7.x-1.7

Or in zip or tar.gz format:
http://drupal.org/node/1668340

monsoon’s picture

I still could not fix this issue.
Restoring to older version left all my side bar menu blocks disappeared.

While creating custom module using above code at #3 stopped site from loading node edit forms and generated error "Too many redirects".

Fugazi-2’s picture

#4 worked for me, thanks.

semiaddict’s picture

#4 seems to work for me as well
Thank you

borutpiletic’s picture

Why this "issue" even exists? Is there someting I am missing about menu translation behaviour?
BTW: you could go with if(strstr($form_id, '_node_form')) instead of regex.
And also this code patch gave an error on node translation form (missing nid).

Here is the quick fix:
if(isset($node->nid) && isset($form['#node']) && $form['#node']->type == 'page' && $language->language != $form['#node']->language)

Overall thanks for sharing this, menu translation now works as expected.

nchase’s picture

with latetest version 7.x-1.10+0-dev this bug still exists. Whenever I edit a node in another language than default the menu item is disabled. total show stopper...

patch in #4 helps.

mastap’s picture

This bug still exists.

flo81’s picture

patch #4 works for me. Thanks.

thehyperlink’s picture

#4 resolves the issue thank you!

ToRum’s picture

Patch #4 works indeed. Thanks!

dosnavigator’s picture

#4 it works. Thank you!

webmestre’s picture

Hi,

I'm getting this issue on a correct 7.41 drupal version.
Any idea to fix it ?