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 |
Jump to:
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
- Create a menu where top level items have sub-menus ;
- Go to admin/build/translate/search and search for all strings in the 'menu' group.
- 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
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
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
Applied, thanks
#7
Automatically closed -- issue fixed for two weeks with no activity.