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
Comment #1
Alice Heaton commentedForgot 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 :
Comment #2
jose reyero commentedI'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
Comment #3
Alice Heaton commentedHi Jose,
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 :
in their hook_init ? This would solve the performance issue for people who don't use DHTML_menu and similar.
Comment #4
cburschkaExcuse 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?
Comment #5
hass commentedComment #6
boobaaSubscribe
Comment #7
rj commentedNote: 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.
Comment #8
rj commentedNote: 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.
Comment #9
jose reyero commentedOnly critical bug fixes for 6.x. Consider upgrading to 7.x