You are here

function admin_language_translated_menu_link_alter in Administration Language 7

Same name and namespace in other branches
  1. 6 admin_language.module \admin_language_translated_menu_link_alter()

Implements hook_translated_menu_link_alter().

File

./admin_language.module, line 118
Makes admin pages be displayed in the administrator's preferred language.

Code

function admin_language_translated_menu_link_alter(&$item, $map) {
  if (('management' == $item['menu_name'] || 'user/logout' == $item['link_path']) && drupal_multilingual()) {
    global $language, $_admin_language;
    if ($language->language !== $_admin_language->language && variable_get('admin_language_translate_admin_menu', 0)) {

      // Save the current language and activate the administration language...
      $current_language = $language;
      $language = $_admin_language;

      // ...modify the menu item...
      _menu_item_localize($item, $map, TRUE);
      if ('user/logout' == $item['link_path']) {
        $item['title'] = t('Log out');
      }
      if ($item['title_callback'] == 't' && !empty($item['title_arguments'])) {
        $item['title'] = t($item['title'], menu_unserialize($item['title_arguments'], $map));
      }

      // ...and restore the previous language
      $language = $current_language;
    }
  }
}