2

What is the proper function to get multi dimensional localized menu in Drupal 7?
after searching, I found i18n_menu_localize_tree(), but I didn't get it as tree menu. Should I use i18n_menu_translated_tree(), or did I miss something?

2

menu_tree($menu_name) Seems to do that. It runs the items through _menu_item_localize.

It works if your menu is translatable. In my setup menu items were not assigned to language, but translated with 18n_menu from site default language.

This atleast gets translated menu. Localized menu might imply also to version where certain items are only shown with specific language active(in that case this answer migth not work).

1

If you use the i18n_menu module for menu translation/localization, you can indeed use the i18n_menu_localize_tree() to retrieve the localized tree of an original given menu tree.

$tree = menu_tree_all_data('main-menu'); // Depending the requirements, you can use menu_tree or menu_tree_all_data

if(module_exists('i18n_menu')) {
    $tree= i18n_menu_localize_tree($tree);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.