Problem

DHTML menu is a module that avoids page reloads when browsing menus ; hierarchical menu items are clickable and uncollapse using javascript to show the sub menu items.

The problem is that when using this module, sub-menu items under branches which are not in the current path do not get translated.

Note that, at the time of writting, to run DHTML menu with i18nmenus the following patch is needed : http://drupal.org/node/298720

Analysis

The problem seems to be that i18nmenu_translated_tree calls menu_tree_page_data which only returns menu data in the current path ; and thus only translates those. However, DHTML menu displays all menu items since they can all be unfolded without a page reload.

This problem is not necessaraly specific to DHTML menu - other modules could have the same problem. i18nmenu_translated_tree cannot make assumptions as to what the tree is going to be used for, and thus must translate all items.

Patch

The following patch fixes the problem :

Index: modules/i18n/i18nmenu/i18nmenu.module
===================================================================
--- modules/i18n/i18nmenu/i18nmenu.module       (revision 1295)
+++ modules/i18n/i18nmenu/i18nmenu.module       (working copy)
@@ -76,7 +76,7 @@
   static $menu_output = array();

   if (!isset($menu_output[$menu_name])) {
-    $tree = menu_tree_page_data($menu_name);
+    $tree = menu_tree_all_data($menu_name);
     i18nmenu_localize_tree($tree);
     $menu_output[$menu_name] = menu_tree_output($tree);
   }

Comments

Alice Heaton’s picture

Forgot to say : at the time of writing, you cannot test this as another bug prevents sub-menus from being translated at all - there is a report and a patch here : http://drupal.org/node/298612 .

So, to re-capitulate, you should :

  1. Apply the patch to i18nmenu, so that sub-menu items are translatable: http://drupal.org/node/298612
  2. Apply the patch to DHTML menu so that it uses the DHTML effect on translated items: http://drupal.org/node/298720
  3. Apply the patch in this bug report to i18nmenu, so that items that are not in the current path get translated
jose reyero’s picture

Component: Module i18nmenu » Compatibility
Assigned: Unassigned » jose reyero
Category: bug » support

I'll take care of (1.)

About (3.) this may have some performance impact for big menus it it would need some if module_exists condition

Alice Heaton’s picture

Hi Jose,

this may have some performance impact for big menus it it would need some if module_exists condition

mmm, the problem is that you don't know in advance which modules will require this ? You don't want to have conditions in i18n for every possible module. On the other hand, i18n is an accepted standard, so it may be easier for the modules themselves to deal with this ? For instance, there could be an API call 'i18n_translate_all_menus' and then DHTML_menu (and other similar modules) could do :

if (module_exists('i18n')) {
  i18n_translate_all_menus();
}

in their hook_init ? This would solve the performance issue for people who don't use DHTML_menu and similar.

cburschka’s picture

Excuse me, but the menu tree doesn't change that often - couldn't you just cache the translated tree to take care of the performance problem?

hass’s picture

Category: support » feature
Status: Active » Needs work
boobaa’s picture

Subscribe

rj’s picture

Note: you can work around this by setting the parent link to expanded so all links automatically appear, and then set DHTML menu to keep only one menu open at a time.

rj’s picture

Note: you can work around this by setting the parent links to be expanded by default and then setting DHTML menu to keep only one menu open at a time.

jose reyero’s picture

Status: Needs work » Closed (won't fix)

Only critical bug fixes for 6.x. Consider upgrading to 7.x