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.

Comments

jose reyero’s picture

Not sure I get it. We provide these api functions so your theme can use them?

neochief’s picture

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.

z.stolar’s picture

Applying the patch solved the problem on my installation

cimo’s picture

Thank you, problem solved

sinasalek’s picture

Jose Reyero - August 5, 2009 - 19:21
Not sure I get it. We provide these api functions so your theme can use them?

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.

sinasalek’s picture

Status: Needs review » Reviewed & tested by the community

Applied the patch and my problem solved. Thanks neochief

hass’s picture

The i18nmenu may need the last module - weight wise... or others may alter the links afterwards not sure about the _preprocess_page order...

sinasalek’s picture

Can modules be weight wise in D6? if they can then i'll try to test it using a module which alts menu.

Zarevac’s picture

Interesting fix, let me try. Any chance of this getting applied in the next release?

Bilmar’s picture

Yes, it would be awesome to have this committed!

jose reyero’s picture

Status: Reviewed & tested by the community » Fixed

Ok, committed, thanks.

(Btw, the module is ready for a new release, some quick testing welcomed)

sinasalek’s picture

Thanks Jose

Status: Fixed » Closed (fixed)

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

jaypan’s picture

This is great... almost! I am setting the language through the domain. I am using example.com for the default language of the site (Japanese) and en.example.com for the second language of the site (Japanese). But the links are being translated even when in en.example.com.

Any idea of how to fix this?

Edit: I figured out how to do it myself. Interesting little fix though. I had to create the menu links in Japanese, then translate them into English! I'm guessing this is because Japanese is the default language.

Either way, this is great! I've tried to translate primary links in the past, and this is the first time I was ever able to actually find a solution that worked. Thanks for doing this in this module.