I want to have exactly the same menu links and structure for all laguages with only Menu link and Description localized. I see that entity menu translation works well for that. All necessary modules enabled.
Now I am creating node in my default language with unchecked button Menu link enabled only for the XXXX language - it works like it should work. Then I create translantion for all languages needed - also with unchecked Menu link enabled only for the XXXX language. Everything works great - One menu link, translanted in all laguages.
The bug is, that when I edit previously created translation of the node on edit node form, the value of Menu link and Description is not localized, but now is loaded the Source language value of Menu link and Description.
When I check Menu link enabled only for the XXXX language, everything works fine, but menu is little bit messy. Mybe that something is missing in hook to load localized values for menu link fields on edit node form.
BTW: Great work!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

plach’s picture

Status: Active » Postponed (maintainer needs more info)

This might be related to #1889084: Menu translation tests broken. Please provide enabled modules and their versions.

danielbehina’s picture

Thank you for your response. It looks like trouble with i18 module: Menu translation is broken, see #1888512: Saving a node breaks menu translation. I will try to downgrade i18 to 7.x-1.7 and will see...

joel_osc’s picture

I think I may have some info to help track this one down...looking at the following code in the i18n_menu.module:

475  * Localize menu item title and description.
    476  *
    477  * This will be invoked always after _menu_item_localize()
    478  *
    479  * Link properties to manage:
    480  * - title, menu router title
    481  * - link_title, menu link title
    482  * - options.attributes.title, menu link description.
    483  * - localized_options.attributes.title,
    484  *
    485  * @see _menu_item_localize()
    486  * @see _menu_link_translate()
    487  */
    488 function _i18n_menu_link_localize(&$link, $langcode = NULL) {
    489   // Only translate title if it has no special callback.
    490   if (empty($link['title callback']) || $link['title callback'] === 't') {
    491     $link['title'] = _i18n_menu_link_title($link, $langcode);
    492   } 
    493   if ($description = _i18n_menu_link_description($link, $langcode)) {
    494     $link['localized_options']['attributes']['title'] = $description;
    495   } 
    496 } 

It looks like $link['title'] is set - which is the menu_router title, but $link['link_title'] is not set. Adding

$link['link_title'] = _i18n_menu_link_title($link, $langcode);

after line 491 seems to fix the issue. I am not really sure this is the correct fix which is why I have not posted a patch to i18n_menu, but I thought I would throw it out to the community to hear some thoughts.

attisan’s picture

had the very same problem - I changed entity_translation_i18n_menu_node_menu_item_translate in line 267 file entity_trnalsation_i18n_menu.module

from

function entity_translation_i18n_menu_node_menu_item_translate($node, $langcode) {
  // Localization.
  if ($node->menu['language'] == LANGUAGE_NONE) {
    _i18n_menu_link_localize($node->menu, $langcode);
  }
  // Translation sets.
  else {
    $menu = NULL;
    if (!empty($node->menu['i18n_tsid']) && $translation_set = ...

to

function entity_translation_i18n_menu_node_menu_item_translate($node, $langcode) {
  // Localization.
  if ($node->menu['language'] == LANGUAGE_NONE) {
    $node->menu['link_title'] = $node->menu['title'];
    _i18n_menu_link_localize($node->menu, $langcode);
  }
  // Translation sets.
  else {
    $menu = NULL;
    if (!empty($node->menu['i18n_tsid']) && $translation_set = ...

hope this will get fixed soon as it's a major thing to have string translated menu (I did never see the point in having extra menu items for every language -> retro style like having a node for each language instead of ET-ing it).

greets,

attisan

plopesc’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
638 bytes

Hello

Attaching a patch that fixes this issue based on attisan's approach. This patch is tested against the environment detailed below:

  • Drupal 7.22
  • i18n 7.x-1.8
  • ET 7.x-1.x-dev / 7.x-1.0-beta2

Regards!

bforchhammer’s picture

Thanks for the patch. I think this is the correct approach.

I added support for the link description, and fixed an issue with translation sets ("separate menu items"); I think this should make the ET menu tests pass again. Let's see what the bot says :)

bforchhammer’s picture

Title: Source language value for Menu link title and description is loaded instead of localized, when updating node on node edit form » Menu translation on node form is broken
Status: Needs review » Fixed

Bot is green, so I went ahead and committed #6. :)

plach’s picture

Cool, thanks!

attisan’s picture

awesome!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

aimara’s picture

Category: bug » support
Priority: Normal » Major
Status: Closed (fixed) » Needs review

hello,
I'd highly appreciate if someone could help me out. I've trying to add this patch http://drupal.org/node/1941080#comment-7293146 to my project, in the specific place it should and it always fails. I am assuming it is the patch because I tried with others and worked perfectly. I'm using NetBeans 7.0 to add patches to my project. Currently working with Drupal 7.22.
Any suggestions?
Thanks in advance.

bforchhammer’s picture

Category: support » bug
Priority: Major » Normal
Status: Needs review » Closed (fixed)

The patch has been committed already, so just use the development version and you should be fine. If something still isn't working correctly, please create a new issue following the bugfixing guidelines outlined on the project page.

danielbehina’s picture

Works great in dev version. Amazing work, guys. Thank you.

schifazl’s picture

Issue summary: View changes
Status: Closed (fixed) » Active

I had this exact issue with the latest version of Drupal and with the latest stable versions of i18n and entity_translation. After reading this bug report I tried to update to the dev version of i18n and entity_translation with no luck, this bug is still present. I had to disable the entity translation menu for the moment.

  • Commit e110c7a on 7.x-1.x, factory, et-fc, revisions by bforchhammer:
    Issue #1941080 by plopesc, bforchhammer: Fixed Menu translation on node...

  • Commit e110c7a on 7.x-1.x, factory, et-fc, revisions, workbench by bforchhammer:
    Issue #1941080 by plopesc, bforchhammer: Fixed Menu translation on node...
kopeboy’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta3

So, I had the latest stable release, and there is the bug.

I went to dev and the bug is still present.

If the patch is actually included in latest dev, it doesn't work.

Let me clarify:
I have the main menu translated with entity translation menu. That creates duplicate entries in admin/structure/menu/manage/main-menu for each language the menu link is translated into.
The module works ok everywhere (only showing the menu links of the chosen language) except for all these pages: node/xxx/edit

When you are editing a node (every node, translatable and untranslatable ones) all the menu links translations are shown, i.e. every menu link is shown twice if you have 2 enabled languages.

The bug is independent on how you added the menu link, being it a custom one, from views, from panels etc.

kopeboy’s picture

Priority: Normal » Major
kopeboy’s picture

Version: 7.x-1.0-beta3 » 7.x-1.x-dev
kopeboy’s picture

The workaround for me was to delete the translated menu links and translate them with i18n_strings.
The setting in the menu is "Translate and localize".

So, can anyone remind me what is Entity translation menu for?
Is it useful only if we don't use string translation on the whole site (which will never be the case in Drupal 7)??

Or was it me misunderstanding how this module should be used (i.e. only with Menu setting "Fixed Language. Menu items will have a global language and they will only show up for pages in that language.")??

Thanks

jide’s picture

I did update both i18n and entity_translation to latest dev, and like @kopeboy, I had no luck making this work. This is unfortunate, since in real life, people do want to use menu items, and without them it almost makes the whole entity_translation module useless.

Bohus Ulrych’s picture

Hello, thank you for your work on this module.
I agree with above that this patch doesn't work with the latest dev version 7.x-1.0-beta3+14-dev.
In my case - just one language version - this "Menu translation: Menu link enabled only for the .. language" didn't worked as expected. Once I checked this I was not able to uncheck it again.
I believe that problem is in the $tset variable in the entity_translation_i18n_menu.module. It expect values 0 or 1, but in my case the right option is LANGUAGE_NONE ( = und).
I put this on line 55 and my issues seems to be solved.
if (!$tset) {
$node->menu['language'] = LANGUAGE_NONE;
}

gnucifer’s picture

As far as I understand it, this is the same issue as the same I'm adding as related? I have this a lot of thought, and perhaps the proposed solution in #2724111 could be a viable option.

gnucifer’s picture