Contributions API

Calling all Drupal developers!

Help us get this on the first page of Digg. DIGG NOW!

Modules in 6

i18nmenu_localize_tree

Definition

i18nmenu_localize_tree(&$tree)
contributions/i18n/i18nmenu/i18nmenu.module, line 127

Description

Localize menu tree

Code

<?php
function i18nmenu_localize_tree(&$tree) {
  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]);
          //dsm("Removed because language:".$link['title'].' language='.$link['options']['langcode']);
        }
      } 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'] = 'Translated';
          $tree[$index]['link']['title'] = tt('menu:item:'.$link['mlid'].':title', $link['link_title'], NULL, TRUE);
        }
      }
    }
  }
}
?>