function i18nmenu_localize_tree in Internationalization 6
Localize menu tree.
3 calls to i18nmenu_localize_tree()
- i18nmenu_locale_refresh in i18nmenu/
i18nmenu.module - Refresh locale strings.
- i18nmenu_menu_navigation_links in i18nmenu/
i18nmenu.module - Return an array of localized links for a navigation menu.
- i18nmenu_translated_tree in i18nmenu/
i18nmenu.module - Get localized menu tree.
File
- i18nmenu/
i18nmenu.module, line 112 - Internationalization (i18n) submodule: Menu translation.
Code
function i18nmenu_localize_tree(&$tree, $update = FALSE) {
global $language;
foreach ($tree as $index => $item) {
$link = $item['link'];
if ($link['customized']) {
// Remove links for other languages than current.
// Links with language wont be localized.
if (!empty($link['options']['langcode'])) {
if ($link['options']['langcode'] != $language->language) {
unset($tree[$index]);
}
}
else {
$router = i18nmenu_get_router($link['router_path']);
// If the title is the same it will be localized by the menu system.
if ($link['link_title'] != $router['title']) {
$tree[$index]['link']['title'] = _i18nmenu_get_item_title($link, $update);
}
$tree[$index]['link']['localized_options']['attributes']['title'] = _i18nmenu_get_item_description($link, $update);
// Localize subtree.
if ($item['below'] !== FALSE) {
i18nmenu_localize_tree($tree[$index]['below'], $update);
}
}
}
}
}