Skip to content

Instantly share code, notes, and snippets.

@BBGuy
Created November 28, 2012 13:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BBGuy/4161371 to your computer and use it in GitHub Desktop.
Save BBGuy/4161371 to your computer and use it in GitHub Desktop.
Drupal - Build a localized menu programmatically using i18n menu
<?php
function i18n_get_menu_get_localized_menu($menu_name) {
// Get the menu tree
$menu_links = menu_tree($menu_name);
// reform the array to be i18n_menu compatible
$l_menu_links = array();
foreach ($menu_links as $key => $value) {
$l_menu_links[$key]['link'] = $value['#original_link'];
}
// localize the menu
if (function_exists('i18n_menu_localize_tree')) {
$l_menu_links = i18n_menu_localize_tree($l_menu_links);
}
return $l_menu_links;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment