Filter menu_tree_all_data() tree by language? My site uses multiple languages and I'm using menu_tree_all_data() to get the menu tree programmatically. Currently all nodes and their translated nodes use the same menu tree.

If I use a menu block the menu that is displayed is filted by language version of the site the user is on. Which is good.

When calling the menu_tree_all_data() in code to build a menu programmatically it returns the entire tree and there does not seem to be an option to filter the menu by a language.

Does anyone know how to get the menu tree in code filted for a specific language?
I suppose you have i18n_menu.module installed. In this case, use i18n_menu_localize_tree($MENU_TREE) to get the tree for the current language.

To get secondary menu, for instance (on template.php):

$tree = menu_tree_all_data('menu-secondary');
$variables['secondary_menu_expanded'] = menu_tree_output(i18n_menu_localize_tree($tree));