Project:Internationalization
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:not translated, problem, submenu, translation

Issue Summary

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

#1

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']);
+    }
   }
}

#2

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']);
+    }
   }
}

#3

It works for me! Good job.

#4

Status:active» reviewed & tested by the community

Same issue, and the patch works forme too.

#5

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

#6

Status:reviewed & tested by the community» fixed

Applied, thanks

#7

Status:fixed» closed (fixed)

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

#8

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

#9

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.

nobody click here