I'm having an issue with menu item translations with custom rendering of menu tree.
I see all languages displayed at the same time whenever I change the current language. Items have translation set it works if I enable the built-in main menu block but not with my code.
I've tried adding 't($string)' and set 'language' in params; but no luck.
What am I doing wrong here ?
I have the following code in template.php for my theme :
function theme_preprocess_page(&$variables) {
$params = array('max_depth' => 3, 'language' => 'fr');
$menu = menu_build_tree('main-menu', $params);
$main_menu_tree = menu_build_tree('main-menu', $params);
$html = '<ul id="dropdown-menu" class="fixed">';
if (arg(0) == 'node' && is_numeric(arg(1)))
$nodeid = arg(1);
foreach ($main_menu_tree as $item_menu) {//for each main element
$isSecondLevel = isset($item_menu['below']) && !empty($item_menu['below']);
$active = '';
if ($item_menu['link']['link_path'] == 'node/' . $nodeid) { $active = 'active';
}
if ($isSecondLevel) {
$html .= '<li>';
} else {
$html .= '<li>';
}
$html .= '<a class="' . $active . '" href="' . url($item_menu['link']['link_path']) . '">';
$html .= $item_menu['link']['link_title'];
$html .= '</a>';
//is there any sub elements to display
if ($isSecondLevel) {
$html .= '<ul class="sub-menu">';
foreach ($item_menu['below'] as $item_submenu) {//for each sub element
$isThirdLevel = isset($item_submenu['below']) && !empty($item_submenu['below']) ? 'main-menu-third_level' : '';
$html .= '<li>';
$html .= '<a href="' . url($item_submenu['link']['link_path']) . '">';
$html .= t($item_submenu['link']['link_title']);
$html .= '</a>';
$html .= '</li>';
}
$html .= '</ul>';
}
$html .= '</li>';
}
$html .= '</ul>';
$variables['main_menu_html'] = $html;
}