function _admin_language_switch_language in Administration Language 7
Same name and namespace in other branches
- 6 admin_language.module \_admin_language_switch_language()
Determine whether the language needs to be switched on the current path.
Return value
bool TRUE to switch to the selected administration language or FALSE to use the default language.
1 call to _admin_language_switch_language()
- admin_language_language_init in ./
admin_language.module - Implements hook_language_init().
File
- ./
admin_language.module, line 749 - Makes admin pages be displayed in the administrator's preferred language.
Code
function _admin_language_switch_language() {
$switch = FALSE;
$visibility = variable_get('admin_language_visibility', ADMIN_LANGUAGE_WHITELIST);
$pages = variable_get('admin_language_pages', ADMIN_LANGUAGE_DEFAULT_PAGES);
// If enabled check the path against the paths defined by hook_admin_paths().
// path_is_admin() can't be used because it relies on functions available in
// higher bootstrap levels only. Thus the module stores and uses a variable
// with the defined admin paths. The variable is updated on every cron run.
if (variable_get('admin_language_use_path_is_admin', TRUE)) {
$patterns = variable_get('admin_language_path_is_admin_paths', array(
'admin' => '',
'non_admin' => '',
));
$switch = FALSE;
if (_admin_language_match_path($_GET['q'], $patterns['admin'])) {
$switch = TRUE;
}
// Provide integration for views paths that are updated via AJAX.
// Can't use module_exists() because it is too early in the bootstrap.
if (!$switch && $_GET['q'] == 'views/ajax' && isset($_REQUEST['view_path'])) {
if (_admin_language_match_path($_REQUEST['view_path'], $patterns['admin'])) {
$switch = TRUE;
}
elseif (_admin_language_match_path($_REQUEST['view_path'], $patterns['non_admin'])) {
$switch = FALSE;
}
}
if (!$switch && _admin_language_match_path($_GET['q'], $patterns['non_admin'])) {
$switch = FALSE;
}
}
if ($pages) {
// We do not need aliases for administration purposes.
$path = request_path();
$switch = $switch || _admin_language_match_path($path, $pages);
if ($path != $_GET['q']) {
$switch = $switch || _admin_language_match_path($_GET['q'], $pages);
}
$switch = !($visibility xor $switch);
}
else {
$switch = TRUE;
$switch = ($visibility xor $switch);
}
// Be sure that your module is initialized on early bootstrap phase to alter
// this variable.
drupal_alter('admin_language_switch', $switch);
return $switch;
}