Problem

I have a menu with sub-menus. When I try to translate the menu item titles, I can only translate the top level menu item titles ; the sub-menu item titles are not available for translation.

How to reproduce

  1. Create a menu where top level items have sub-menus ;
  2. Go to admin/build/translate/search and search for all strings in the 'menu' group.
  3. Only the top-level menu item titles appear

Patch

The problem seems to be that function i18nmenu_localize_tree does not recurse. The following patch (against the august 14 dev build) fixes this :

Index: modules/i18n/i18nmenu/i18nmenu.module
===================================================================
--- modules/i18n/i18nmenu/i18nmenu.module       (revision 1176)
+++ modules/i18n/i18nmenu/i18nmenu.module       (working copy)
@@ -107,6 +107,10 @@
         }
       }
     }
+
+    if ($item['below'] !== false) {
+      i18nmenu_localize_tree($item['below']);
+    }
   }
 }

Comments

Alice Heaton’s picture

oops, the patch I posted above fixes the problem that sub-menu items are not available for translation -- but then those translations are not displayed ! Here is a new patch which fixes this. This patch superseed the original patch posted with the issue :

Index: modules/i18n/i18nmenu/i18nmenu.module
===================================================================
--- modules/i18n/i18nmenu/i18nmenu.module       (revision 1176)
+++ modules/i18n/i18nmenu/i18nmenu.module       (working copy)
@@ -107,6 +107,10 @@
         }
       }
     }
+
+    if ($item['below'] !== false) {
+      i18nmenu_localize_tree($tree[$index]['below']);
+    }
   }
}
Alice Heaton’s picture

Third time lucky, there are times where 'below' is NULL rather than FALSE; so to be safe this patch (which superseeds both patches above) should cover all posibilities :

Index: modules/i18n/i18nmenu/i18nmenu.module
===================================================================
--- modules/i18n/i18nmenu/i18nmenu.module       (revision 1176)
+++ modules/i18n/i18nmenu/i18nmenu.module       (working copy)
@@ -107,6 +107,10 @@
         }
       }
     }
+
+    if (is_array($tree[$index]['below'])) {
+      i18nmenu_localize_tree($tree[$index]['below']);
+    }
   }
}
filip.jurcicek’s picture

It works for me! Good job.

zmove’s picture

Status: Active » Reviewed & tested by the community

Same issue, and the patch works forme too.

zmove’s picture

I pop up this patch because there had a new dev release of i18n and this patch was not committed.

jose reyero’s picture

Status: Reviewed & tested by the community » Fixed

Applied, thanks

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

prodosh’s picture

This problem has reappeared in Internationalization 6.x-1.9 on Drupal 6.20. Will the patch posted here still work?

prodosh’s picture

The problem was fixed by setting the language of the menu items to "All Languages" instead of English or German.
This problem was probably unrelated to this thread.