I have installed Menutrail on a multilingual site running on three domains, one for each language. Each language has another primary links menu. The settings are saved separately using this in my settings.php: (after this tip here http://drupal.org/node/165527#comment-870834).

$conf['i18n_variables'] = array(
  'menutrails_menu',
  'menutrails_node_types',
  'menutrails_terms',
);

Now everything works great, it even works for the Biblio node-type (from Biblio module. BUT, for some reason it only works on one of the menus, the English one. On the other two domains, using different primary menus, only for the Biblio type the correct parent menu will not be set. I've spent hours reading about and trying all kinds of tricks, no luck. But since it works for one language/menu with Menutrails, any suggestions to make it work?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joshk’s picture

Title: Menutrails works for biblio node-type in one menu, but not the other - howto fix? » Implement i18n menu support
Category: support » feature

I'm willing to bet there is additional code needed to support internationalization. This will need some further research to figure out. Thanks for bringing this to my attention!

ar-jan’s picture

Cool, I'll be available for testing when there are new developments.

joshk’s picture

Excellent. I saw all the code in the other thread here:

http://drupal.org/node/165527

It'll probably be some days before I really have time to dig into it, but i18n is an important feature (esp for Drupal 6) and I want to support it.

sharlak’s picture

I added 'menutrails_menu', 'menutrails_node_types' and 'menutrails_terms' to 'i18n_variables' in my settings.php as it has been said here and tested it. For the moment everything seems to work fine. I have created a menu for my Spanish content (called Test-es) and another one for its translation to Basque (called Test-eu). After configuring menu trails module in both languages I got the active-trail class in the defined parent items as I expected (using both nodetypes and taxonomy configuration), so I think that this solves the issue.

I'm using Internationalization 6.x-1.0 and Menu Trails 6.x-1.0. Can anyone give more feedback?

tibbsa’s picture

I have tried, unsuccessfully, to use Menu Trails on a new bilingual (French/English) D6 site. I added the menutrails_* variables to the i18n_variables list in settings.php (as I have done for numerous other modules, so I know this 'works'), and this did indeed allow me to configure separate English & French assignments in the UI.

On this site, two site-specific menus are used (i.e. not Primary or Secondary links) - one for English and one for French.

Associating by node type or taxonomy works great for the primary language (English), and results in appropriate breadcrumbs and "active" item indication.

It does not appear to be doing anything at all when operating in French, however.

Is there anywhere or anything else I could check?

domidc’s picture

Set the multilingual variables. If you have urls going to the same path in both languages like a view that has a language filter for example, you need to hack the module a little.
To the owner of this module: proper i18n support would be nicer, but for now this fix works fine for me.

Change this function :

function _menutrails_parents_recurse($tree, $menu_name, $indent, &$options, $exclude, $depth_limit) {
  foreach ($tree as $data) {
    if ($data['link']['depth'] > $depth_limit) {
      // Don't iterate through any links on this level.
      break;
    }
    if ($data['link']['mlid'] != $exclude && $data['link']['hidden'] >= 0) {
      $title = $indent .' '. truncate_utf8($data['link']['title'], 30, TRUE, FALSE);
      if (!$data['link']['hidden']) {
        $options[$data['link']['href']] = $title;
      }
      if ($data['below']) {
        _menutrails_parents_recurse($data['below'], $menu_name, $indent .'--', $options, $exclude, $depth_limit);
      }
    }
  }
}

Into:

function _menutrails_parents_recurse($tree, $menu_name, $indent, &$options, $exclude, $depth_limit) {
  foreach ($tree as $data) {
    if ($data['link']['depth'] > $depth_limit) {
      // Don't iterate through any links on this level.
      break;
    }
    if ($data['link']['mlid'] != $exclude && $data['link']['hidden'] >= 0) {
      $title = $indent .' '. truncate_utf8($data['link']['title'], 30, TRUE, FALSE);
      if (!$data['link']['hidden']) {
        if (module_exists('i18n')) {
          if (i18n_get_lang() == $data['link']['localized_options']['langcode']) {
            $options[$data['link']['href']] = $title;
          }
        }
        else {
        	$options[$data['link']['href']] = $title;
        }
      }
      if ($data['below']) {
        _menutrails_parents_recurse($data['below'], $menu_name, $indent .'--', $options, $exclude, $depth_limit);
      }
    }
  }
}
marcushenningsen’s picture

I can confirm that entering the above mentioned lines of code into settings.php works perfectly. This, however, seems like a workaround. Should this somehow be entered into the module itself?

DomoSapiens’s picture

I have the same problem, but adding the 'i18n_variables' did the trick for me.
It works great! Thanks

loominade’s picture

subscribe

paoloteo’s picture

FileSize
1.87 KB

Confirming that this at the end of the settings.php

$conf['i18n_variables'] = array(
'menutrails_menu',
'menutrails_node_types',
'menutrails_terms',
);

and applying the patch I attached with the above code from #6 works great.

loominade’s picture

maybe you should use http://drupal.org/project/node_breadcrumb instead

James Andres’s picture

Status: Active » Needs review
FileSize
1.33 KB

This patch is a simpler approach IMO, it uses the i18nmenu_localize_tree() function to transparently switch to a localized menu tree which allows the rest of menutrails to keep on running without knowing the difference.

iamjon’s picture

Subscribing

gease’s picture

Patch #12 worked perfectly - for a single multi-lingual menu. Many thanks, James.

rj’s picture

FileSize
1.39 KB

The attached patch is the same as #12 except that it allows menutrails to play nice with the i18nmenu_node module by calling menu_tree_all_data instead of menu_tree_page_data.

gease’s picture

Neither #12 nor #15 "plays nicely" with i18nmenu_node. #12 doesn't show breadcrumbs. #15 doesn't show links in the menu.

rj’s picture

Regarding #16, breadcrumbs and menu links display properly for me. You may want to check your config settings, and possibly check for conflict with another module. Also, if you're using DHTML menu, you'll need to set all parent links to be expanded, see http://drupal.org/node/299783#comment-3781566.

gease’s picture

@rj,
I wonder how you manage to get breadcrumbs displayed, given menu_tree_all_data has even different signature from menu_tree_page_data and requires second parameter to set 'in_active_trail' property. AFAICS, there is no way to get breadcrumbs with menu_tree_all_data(). Instead, using patch from #12 and setting content negotiation to "all languages" solves the problem, but that's not the perfect way.
To display everything correctly, I did the following:
1. Added

    if (module_exists('i18nmenu_node')) {
    i18nmenu_node_navigation_links_prepare();
  } 

before the call to menu_tree_page_data in menutrails_get_breadcrumbs() to get menu cache set up correctly. But this broke theme settings cache, so
2. I changed theme_get_setting('zen_breadcrumb'); to theme_get_setting('zen_breadcrumb', TRUE); in zen_breadcrumb (in fact, I overrode zen_breadcrumb in my sub-theme).
This seems like an ugly solution to me, but the only one that works. Hopefully someone can come up with something better.

rj’s picture

Doh, I'm using the custom_breadcrumb module for breadcrumbs, not menutrail, which is probably why breadcrumbs are working. Have you tried calling i18nmenu_node_navigation_links_prepare() from hook_nodeapi('view')? Maybe that would do the trick?

einpol’s picture

any news on this topic?? -.-

MXT’s picture

Subscribing

gkom’s picture

Subscribing

dmotilla’s picture

FileSize
624 bytes

I have added in menutrails_get_breadcrumbs function, after $tree = menu_tree_page_data($menu); the following code:

  //i18n menu integration
  if(module_exists('i18nmenu')){
    i18nmenu_localize_tree($tree);
  }

I think this function is that translates the tree as the language of each item. What do you think is the best solution?

marco.giaco’s picture

Version: 6.x-1.x-dev » 6.x-1.1

What about this? It is the only working in my case

@@ -104,9 +103,9 @@ function _menutrails_recurse_crumbs($tree, $item, &$crumbs, $above = array()) {
}
if ($menu_item['link']['link_path'] == $item['href']) {
foreach ($above as $trail_item) {
- $crumbs[] = l($trail_item['link']['link_title'], $trail_item['link']['link_path']);
+ $crumbs[] = l(t($trail_item['link']['link_title']), $trail_item['link']['link_path']);
}
- $crumbs[] = l($menu_item['link']['link_title'], $menu_item['link']['link_path']);
+ $crumbs[] = l(t($menu_item['link']['link_title']), $menu_item['link']['link_path']);
break;
}

-otto-’s picture

Subscribing

Einkahumor’s picture

I could not get this working properly with any of the methods in this issue so I gave up in the end. I tried out Node Breadcrumb but eventually gave up on that one too because of a totally unrelated but equally show-stopping (for my current project) issue. I ended up using Menu Position and that one worked quite nicely (6.x needed to be patched for multilingual support but it actually worked). It even seems to have an excellent 7.x version.

Just thought I'd post this info so it might be of help to some.