View source
<?php
define('LANGUAGE_NEGOTIATION_ADMINISTRATION', 'language-administration');
function administration_language_negotiation_menu() {
$items = array();
$items['admin/config/regional/language/configure/administration_language'] = array(
'title' => 'Administration language negotiation',
'description' => 'Configure the administration language negotiation',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'administration_language_negotiation_admin',
),
'access arguments' => array(
'administer languages',
),
'file' => 'administration_language_negotiation.admin.inc',
'type' => MENU_VISIBLE_IN_BREADCRUMB,
);
return $items;
}
function administration_language_negotiation_language_negotiation_info() {
return array(
LANGUAGE_NEGOTIATION_ADMINISTRATION => array(
'types' => array(
LANGUAGE_TYPE_INTERFACE,
),
'callbacks' => array(
'language' => 'administration_language_negotiation_admin_language',
),
'file' => drupal_get_path('module', 'administration_language_negotiation') . '/administration_language_negotiation.module',
'weight' => -50,
'name' => t('Administration path'),
'description' => t('Set a default language on specific paths.'),
'config' => 'admin/config/regional/language/configure/administration_language',
'cache' => 0,
),
);
}
function administration_language_negotiation_admin_language() {
require_once 'includes/path.inc';
if (_administration_language_negotiation_admin_get_language(current_path())) {
return variable_get('administration_language_negotiation_default', FALSE);
}
return FALSE;
}
function _administration_language_negotiation_admin_get_language($path_to_check) {
$admin_path = implode("\n", array_filter(variable_get('administration_language_negotiation_paths', array())));
if (drupal_match_path($path_to_check, $admin_path)) {
return TRUE;
}
return FALSE;
}