sub-menu items not localized

Anselm Heaton - August 22, 2008 - 13:06
Project:Internationalization
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

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

#1

Anselm Heaton - August 25, 2008 - 16:15

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

Anselm Heaton - August 26, 2008 - 09:06

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

filip.jurcicek - August 26, 2008 - 17:40

It works for me! Good job.

#4

zmove - August 28, 2008 - 13:44
Status:active» reviewed & tested by the community

Same issue, and the patch works forme too.

#5

zmove - September 9, 2008 - 11:53

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

#6

Jose Reyero - September 26, 2008 - 12:14
Status:reviewed & tested by the community» fixed

Applied, thanks

#7

Anonymous (not verified) - October 10, 2008 - 12:22
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.