Primary and secondary links' menus translation
| Project: | Internationalization |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | fixed |
Jump to:
As you may know, there's some problems with translation of standard primary and secondary links when you show them not as blocks (http://drupal.org/node/313302). This cause duplicate menu items in primary and secondary menus without respect to selected language.
The solution is quite simply. We should override template variables $primary_links and $secondary links, so they will contain proper data when passed to page.tpl.php.
I prepared a patch which does this.
Some explanation
Contents of i18nmenu_preprocess_page() is very similar to menu_primary_links() and menu_secondary_links(), except that it calls i18nmenu_menu_navigation_links() in place of core' smenu_navigation_links().
i18nmenu_menu_navigation_links() function is the copy of core's menu_navigation_links() but with only one difference — it contains i18nmenu_localize_tree() call, which handles localized menu items.
Yes, we got some duplicate code here, but there's no other way to hook-up there. I think that 20 lines of code is a fair price to leave all of menu-per-language boogee-woogees in past.
| Attachment | Size |
|---|---|
| i18nmenu-primary-secondary-links-fix.patch | 2.67 KB |

#1
Not sure I get it. We provide these api functions so your theme can use them?
#2
Yes, it can be pasted into the theme, but why we not fix this thing by our own? There are lots of issues about primary links translations, and currently only way to do it is to show them as block. My patch solves the issue for any theme out of the box.
#3
Applying the patch solved the problem on my installation
#4
Thank you, problem solved
#5
I disagree with you, i localized my primary and secondary links so i expected to see it working on any theme but it didn't.
#6
Applied the patch and my problem solved. Thanks neochief
#7
The i18nmenu may need the last module - weight wise... or others may alter the links afterwards not sure about the _preprocess_page order...
#8
Can modules be weight wise in D6? if they can then i'll try to test it using a module which alts menu.
#9
Interesting fix, let me try. Any chance of this getting applied in the next release?
#10
Yes, it would be awesome to have this committed!
#11
Ok, committed, thanks.
(Btw, the module is ready for a new release, some quick testing welcomed)
#12
Thanks Jose