When a menu links to a node, ex. node/123 you cannot set it's language, because:

This menu item belongs to a node, so it will have the same language as the node and cannot be localized.

But, in the form you will see Language: Undefined
I created a patch for i18n_menu.module to read the language from $node object.

Comments

gabrielu’s picture

Status: Active » Needs review
StatusFileSize
new1.09 KB

See attachement.

Status: Needs review » Needs work

The last submitted patch, 1594804-menu_node_language.patch, failed testing.

gabrielu’s picture

Status: Needs work » Needs review
StatusFileSize
new995 bytes

Reattaching

jose reyero’s picture

Status: Needs review » Needs work

Maybe the actual bug is 'why the menu item doesn't get the node language?', not fixing it later.

gabrielu’s picture

Should the menu item get language from the node? What happens when you change language of a node, should you go to the menu_item and update the language?

I'm not sure I understand how it works at the moment, since the menus are shown correctly on the site, but not in the admin.

a6hiji7’s picture

I was having the same problem and it was driving me nuts for sometime. Then I noticed that if I change the content language to "Language neutral", then save and then edit and change to the correct language and save again, the menu language gets fixed. Good that I don't have to apply a patch!

jide’s picture

In fact, this issue is caused by a misconfiguration of the menu settings in a content type.
If you manually added a menu link pointing to a node in a menu that is not enabled for this content type, then it will fail to get the menu item language.

To fix it, just edit the content type and add the menu in the available menus. Then if you save content again, menu item language will be correct.

jose reyero’s picture

I think the reason is well explained by @jide in #7

About the patch, it won't work for new menu items created. This should be done when creating/updating new menu items, not in the form.

gabrielu’s picture

Normally the patch should be display only, nothing related to functionality.
But if #7 is correct, the we shouldn't need the patch, rather than think of a way the menu module would take language even if it's not configured in the conten-type.

Gabriel

Fidelix’s picture

If you manually added a menu link pointing to a node in a menu that is not enabled for this content type, then it will fail to get the menu item language.

To fix it, just edit the content type and add the menu in the available menus. Then if you save content again, menu item language will be correct.

No. In my case, the menu is enabled for the correct content types, and when I change something, export the feature and revert it on another site, all the links lose language information, and become "Undefined". Just like that.

Not even with the patch in #3 this is working for me.

Edit: Please, ignore. It appears this problem is with the Features module:
http://drupal.org/project/issues/features?text=menu+language

mvc’s picture

hermes_costell’s picture

Issue summary: View changes

To fix it, just edit the content type and add the menu in the available menus. Then if you save content again, menu item language will be correct.

+1

I had all items for both languages (English and Italian) showing at the same time. For others encountering this, here is what worked for me:

  1. The content type in question: Go to edit screen (admin/structure/types/manage/CONTENT_TYPE) -> Multilingual Settings ->select Require language (Do not allow Language Neutral).
  2. The menu in question: enable all links (in my case both English and Italian)
  3. Click on each page in the menu one-by-one, go to the Edit page for the item (click the Edit tab at the top). Simply click save at the bottom.
  4. Done.
zvs’s picture

Status: Needs work » Needs review
jose reyero’s picture

Status: Needs review » Closed (works as designed)

For all I've read, it seems this was caused by some misconfiguration.

Also the patch just fixes how it is displayed on the form, which may confuse more than help (you are seeing different values from what it's stored in the database).

Feel free to add this to the module's handbook, but we don't really need this patch.

fer051’s picture

otra opción cuando se edita un link del menu es: momentáneamente copiar la ruta del nodo y cambiar la ruta del path por o guardarlo, al volver a editar el Link, si permitirá seleccionar el idioma que queremos para el nodo, restaurar la ruta de nuestro nodo en el path, guardar, y luego traducir....
===================================================================
(translate with google)temporarily copy the path node and change the path by or < nolink > save it, to re-edit the link, if you to select the language, you want for the node, restore the path of our node, save , and then translate ....

miroslavbanov’s picture

Version: 7.x-1.5 » 7.x-1.x-dev
Status: Closed (works as designed) » Needs work

This is a real, reproducible issue:

When creating a menu link from admin/structure/menu/manage/{menu}/add :

  1. You can set the language while creating, but you can't change it.
  2. There is nothing in 18n_menu to ensure that the language is set correctly.

I can forget to set language, or set incorrect language. After that I see the message "This menu item belongs to a node, so it will have the same language as the node and cannot be localized." - which is misleading as it may not have the same language as the node, and I can't fix it.

If we are disallowing setting of language, there must be something that automatically sets correct language.

miroslavbanov’s picture

Status: Needs work » Needs review
StatusFileSize
new1.07 KB

Trying to fix it by setting language on menu link save.

ckng’s picture

Rerolled #17 for dev. Tested working.

joseph.olstad’s picture

adding some tests for php 5.4 , 5.5, and php 7

joseph.olstad’s picture

So no reported regressions from patch #18 ?

is it possible for someone to write a simpletest for this?

q11q11’s picture

Rerolled #18 aganist 7.x-1.26, just couple offsets.