I am trying to translate a menu item, here are the steps i took:

    Main language is set to NL (dutch), second language to EN (English)
    Set the main menu to: Translate and Localize. Items with language will allow translations. Items without language will be localized.
    Created a views page with a menu item in the main menu
    Located and translated the string in nl/admin/config/regional/translate/translate
    On the page nl/admin/config/regional/translate/i18n_string i refreshed the menu strings and updated the English language

But still when i visit the /en page the menu item is not translated. Any help would be appreciated.

Comments

bluemaro’s picture

Are you using a nice menu module for your main menu? I had a similar problem with that module. I've noticed that in i18n_menu_localize_tree function (i18n_menu.module) probably wrong value is translated?

In current version:

if ($link['link_title'] != $router['title']) {
    $item['link']['title'] = _i18n_menu_link_title($link, $langcode);
}

Shouldn't it be?:

if ($link['link_title'] != $router['title']) {
    $item['link']['link_title'] = _i18n_menu_link_title($link, $langcode);
}

I'm a new drupal user so I'm not sure whether it's a bug in i18n_menu module or in a nice menu module which uses $link['link_title'] value instead of $link['title']. Can anyone confirm that?

Michsk’s picture

Thanks for the input, it did not solve the issue tough. I am not using a menu module, the way i display the menu is trough a block in a region.

Michsk’s picture

When i do a:

print_r($link);

in i18n_menu.module @365, then the translated string isn't even in the $link array.

jose reyero’s picture

It's in the $item array.

jose reyero’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

ClaudeS-1’s picture

I've had major problems getting MegaMenu menu items to be localized (using i18n 7.x-1.4). First problem was that MegaMenu had no localization functionality built in.
Second problem was exactly what bluemaro found, and I'm surprised that a year later the error is still there...

I don't understand how localization is working for people with this code, as the localized title never overwrites the default title in the $tree variable. You're probably right that many menus are incorrectly/cheekily using $link['title'] instead of $link['link_title']

This post is the first (only?) reference I've found to the typo, so will take the appropriate actions to get it looked into.

versantus.nik’s picture

@ClaudeS did you find anything more about this? I'm having problems with Nice Menus and localization - specifically it appears that the "title" is being translated, but the "link_title" is used in the output (and so is not translated).

Like you, I'm surprised this isn't more prevalent, so perhaps there's a combination of factors involved?