function admin_language_menu_local_tasks_alter in Administration Language 7
Implements hook_menu_local_tasks_alter().
File
- ./
admin_language.module, line 71 - Makes admin pages be displayed in the administrator's preferred language.
Code
function admin_language_menu_local_tasks_alter(&$data, $router_item, $root_path) {
if (drupal_multilingual() && variable_get('admin_language_translate_local_tasks', 0)) {
global $language;
global $user;
$admin_language = admin_language_retrieve();
if ($admin_language->language != $language->language) {
// Switch the site's language to the admin language.
$site_language = $language;
$language = $admin_language;
// Retrieve the English versions of the local tasks so they can be
// re-translated into the admin language.
$result = db_select('menu_router', NULL, array(
'fetch' => PDO::FETCH_ASSOC,
))
->fields('menu_router')
->condition('tab_root', $router_item['tab_root'])
->condition('context', MENU_CONTEXT_INLINE, '<>')
->orderBy('weight')
->orderBy('title')
->execute();
$map = $router_item['original_map'];
$children = array();
$translated_tasks = array();
$root_path = $router_item['path'];
foreach ($result as $item) {
foreach ($data['tabs'] as &$tab_row) {
foreach ($tab_row['output'] as &$tab) {
if ($item['path'] == $tab['#link']['path']) {
_menu_translate($item, $map, TRUE);
$tab['#link'] = $item;
}
}
}
}
// Switch the language back.
$language = $site_language;
}
}
}