You are here

function i18nmenu_menu_link_alter in Internationalization 6

Implementation of hook_menu_link_alter().

Catch changed links, update language and set alter option.

File

i18nmenu/i18nmenu.module, line 45
Internationalization (i18n) submodule: Menu translation.

Code

function i18nmenu_menu_link_alter(&$item, $menu) {

  // If we set option to language it causes an error with the link system
  // This should handle language only as the links are being manually updated
  if (!empty($item['language'])) {
    $item['options']['langcode'] = $item['language'];
  }
  elseif (isset($item['language'])) {
    unset($item['options']['langcode']);
  }

  // If we are handling custom menu items of menu module and no language is set,
  // invoke translation via i18nstrings module.
  if (empty($item['language']) && $item['module'] == 'menu') {

    // Set title_callback to FALSE to avoid calling t().
    $item['title_callback'] = FALSE;

    // Setting the alter option to true ensures that
    // hook_translated_menu_link_alter() will be called.
    $item['options']['alter'] = TRUE;
  }
}