Commit 03a8bdc3 authored by Dries's avatar Dries

- Patch #1431040 by Gábor Hojtsy: rename LOCALE_LANGUAGE_NEGOTIATION_*...

- Patch #1431040 by Gábor Hojtsy: rename LOCALE_LANGUAGE_NEGOTIATION_* constants to LANGUAGE_NEGOTIATION_*.
parent 51867cdc
......@@ -9,33 +9,33 @@
* The language is determined using a URL language indicator:
* path prefix or domain according to the configuration.
*/
const LOCALE_LANGUAGE_NEGOTIATION_URL = 'locale-url';
const LANGUAGE_NEGOTIATION_URL = 'locale-url';
/**
* The language is set based on the browser language settings.
*/
const LOCALE_LANGUAGE_NEGOTIATION_BROWSER = 'locale-browser';
const LANGUAGE_NEGOTIATION_BROWSER = 'locale-browser';
/**
* The language is determined using the current interface language.
*/
const LOCALE_LANGUAGE_NEGOTIATION_INTERFACE = 'locale-interface';
const LANGUAGE_NEGOTIATION_INTERFACE = 'locale-interface';
/**
* If no URL language is available language is determined using an already
* detected one.
*/
const LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK = 'locale-url-fallback';
const LANGUAGE_NEGOTIATION_URL_FALLBACK = 'locale-url-fallback';
/**
* The language is set based on the user language settings.
*/
const LOCALE_LANGUAGE_NEGOTIATION_USER = 'locale-user';
const LANGUAGE_NEGOTIATION_USER = 'locale-user';
/**
* The language is set based on the request/session parameters.
*/
const LOCALE_LANGUAGE_NEGOTIATION_SESSION = 'locale-session';
const LANGUAGE_NEGOTIATION_SESSION = 'locale-session';
/**
* Regular expression pattern used to localize JavaScript strings.
......@@ -88,13 +88,13 @@
* URL language negotiation: use the path prefix as URL language
* indicator.
*/
const LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX = 0;
const LANGUAGE_NEGOTIATION_URL_PREFIX = 0;
/**
* URL language negotiation: use the domain as URL language
* indicator.
*/
const LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN = 1;
const LANGUAGE_NEGOTIATION_URL_DOMAIN = 1;
/**
* @defgroup locale-languages-negotiation Language negotiation options
......@@ -264,12 +264,12 @@ function locale_language_from_session($languages) {
function locale_language_from_url($languages) {
$language_url = FALSE;
if (!language_negotiation_get_any(LOCALE_LANGUAGE_NEGOTIATION_URL)) {
if (!language_negotiation_get_any(LANGUAGE_NEGOTIATION_URL)) {
return $language_url;
}
switch (variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX)) {
case LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX:
switch (variable_get('locale_language_negotiation_url_part', LANGUAGE_NEGOTIATION_URL_PREFIX)) {
case LANGUAGE_NEGOTIATION_URL_PREFIX:
// $_GET['q'] might not be available at this time, because
// path initialization runs after the language bootstrap phase.
list($language, $_GET['q']) = language_url_split_prefix(isset($_GET['q']) ? $_GET['q'] : NULL, $languages);
......@@ -278,7 +278,7 @@ function locale_language_from_url($languages) {
}
break;
case LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN:
case LANGUAGE_NEGOTIATION_URL_DOMAIN:
$domains = locale_language_negotiation_url_domains();
foreach ($languages as $language) {
// Skip check if the language doesn't have a domain.
......@@ -333,7 +333,7 @@ function locale_language_from_url($languages) {
*/
function locale_language_url_fallback($language = NULL, $language_type = LANGUAGE_TYPE_INTERFACE) {
$default = language_default();
$prefix = (variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX);
$prefix = (variable_get('locale_language_negotiation_url_part', LANGUAGE_NEGOTIATION_URL_PREFIX) == LANGUAGE_NEGOTIATION_URL_PREFIX);
// If the default language is not configured to convey language information,
// a missing URL language information indicates that URL language should be
......@@ -433,8 +433,8 @@ function locale_language_url_rewrite_url(&$path, &$options) {
}
if (isset($options['language'])) {
switch (variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX)) {
case LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN:
switch (variable_get('locale_language_negotiation_url_part', LANGUAGE_NEGOTIATION_URL_PREFIX)) {
case LANGUAGE_NEGOTIATION_URL_DOMAIN:
$domains = locale_language_negotiation_url_domains();
if (!empty($domains[$options['language']->langcode])) {
// Ask for an absolute URL with our modified base_url.
......@@ -443,7 +443,7 @@ function locale_language_url_rewrite_url(&$path, &$options) {
}
break;
case LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX:
case LANGUAGE_NEGOTIATION_URL_PREFIX:
$prefixes = locale_language_negotiation_url_prefixes();
if (!empty($prefixes[$options['language']->langcode])) {
$options['prefix'] = $prefixes[$options['language']->langcode] . '/';
......@@ -496,7 +496,7 @@ function locale_language_url_rewrite_session(&$path, &$options) {
$languages = language_list(TRUE);
$query_param = check_plain(variable_get('locale_language_negotiation_session_param', 'language'));
$query_value = isset($_GET[$query_param]) ? check_plain($_GET[$query_param]) : NULL;
$query_rewrite = isset($languages[$query_value]) && language_negotiation_get_any(LOCALE_LANGUAGE_NEGOTIATION_SESSION);
$query_rewrite = isset($languages[$query_value]) && language_negotiation_get_any(LANGUAGE_NEGOTIATION_SESSION);
}
else {
$query_rewrite = FALSE;
......
......@@ -223,10 +223,10 @@ function locale_language_providers_url_form($form, &$form_state) {
'#title' => t('Part of the URL that determines language'),
'#type' => 'radios',
'#options' => array(
LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX => t('Path prefix'),
LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN => t('Domain'),
LANGUAGE_NEGOTIATION_URL_PREFIX => t('Path prefix'),
LANGUAGE_NEGOTIATION_URL_DOMAIN => t('Domain'),
),
'#default_value' => variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX),
'#default_value' => variable_get('locale_language_negotiation_url_part', LANGUAGE_NEGOTIATION_URL_PREFIX),
);
$form['prefix'] = array(
......@@ -237,7 +237,7 @@ function locale_language_providers_url_form($form, &$form_state) {
'#states' => array(
'visible' => array(
':input[name="locale_language_negotiation_url_part"]' => array(
'value' => (string) LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX,
'value' => (string) LANGUAGE_NEGOTIATION_URL_PREFIX,
),
),
),
......@@ -250,7 +250,7 @@ function locale_language_providers_url_form($form, &$form_state) {
'#states' => array(
'visible' => array(
':input[name="locale_language_negotiation_url_part"]' => array(
'value' => (string) LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN,
'value' => (string) LANGUAGE_NEGOTIATION_URL_DOMAIN,
),
),
),
......@@ -303,7 +303,7 @@ function locale_language_providers_url_form_validate($form, &$form_state) {
$value = $form_state['values']['prefix'][$langcode];
if ($value === '') {
if (!$language->default && $form_state['values']['locale_language_negotiation_url_part'] == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) {
if (!$language->default && $form_state['values']['locale_language_negotiation_url_part'] == LANGUAGE_NEGOTIATION_URL_PREFIX) {
// Validation error if the prefix is blank for a non-default language, and value is for selected negotiation type.
form_error($form['prefix'][$langcode], t('The prefix may only be left blank for the default language.'));
}
......@@ -320,7 +320,7 @@ function locale_language_providers_url_form_validate($form, &$form_state) {
$value = $form_state['values']['domain'][$langcode];
if ($value === '') {
if (!$language->default && $form_state['values']['locale_language_negotiation_url_part'] == LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN) {
if (!$language->default && $form_state['values']['locale_language_negotiation_url_part'] == LANGUAGE_NEGOTIATION_URL_DOMAIN) {
// Validation error if the domain is blank for a non-default language, and value is for selected negotiation type.
form_error($form['domain'][$langcode], t('The domain may only be left blank for the default language.'));
}
......
......@@ -17,14 +17,14 @@ function locale_install() {
// We cannot rely on language negotiation hooks here, because locale module is
// not enabled yet. Therefore language_negotiation_set() cannot be used.
$info = locale_language_negotiation_info();
$provider = $info[LOCALE_LANGUAGE_NEGOTIATION_URL];
$provider = $info[LANGUAGE_NEGOTIATION_URL];
$provider_fields = array('callbacks', 'file', 'cache');
$negotiation = array();
// Store only the needed data.
foreach ($provider_fields as $field) {
if (isset($provider[$field])) {
$negotiation[LOCALE_LANGUAGE_NEGOTIATION_URL][$field] = $provider[$field];
$negotiation[LANGUAGE_NEGOTIATION_URL][$field] = $provider[$field];
}
}
......
......@@ -450,10 +450,10 @@ function locale_language_types_info() {
LANGUAGE_TYPE_CONTENT => array(
'name' => t('Content'),
'description' => t('Order of language detection methods for content. If a version of content is available in the detected language, it will be displayed.'),
'fixed' => array(LOCALE_LANGUAGE_NEGOTIATION_INTERFACE),
'fixed' => array(LANGUAGE_NEGOTIATION_INTERFACE),
),
LANGUAGE_TYPE_URL => array(
'fixed' => array(LOCALE_LANGUAGE_NEGOTIATION_URL, LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK),
'fixed' => array(LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_URL_FALLBACK),
),
);
}
......@@ -466,7 +466,7 @@ function locale_language_negotiation_info() {
$file = '/core/includes/locale.inc';
$providers = array();
$providers[LOCALE_LANGUAGE_NEGOTIATION_URL] = array(
$providers[LANGUAGE_NEGOTIATION_URL] = array(
'types' => array(LANGUAGE_TYPE_CONTENT, LANGUAGE_TYPE_INTERFACE, LANGUAGE_TYPE_URL),
'callbacks' => array(
'language' => 'locale_language_from_url',
......@@ -480,7 +480,7 @@ function locale_language_negotiation_info() {
'config' => 'admin/config/regional/language/configure/url',
);
$providers[LOCALE_LANGUAGE_NEGOTIATION_SESSION] = array(
$providers[LANGUAGE_NEGOTIATION_SESSION] = array(
'callbacks' => array(
'language' => 'locale_language_from_session',
'switcher' => 'locale_language_switcher_session',
......@@ -493,7 +493,7 @@ function locale_language_negotiation_info() {
'config' => 'admin/config/regional/language/configure/session',
);
$providers[LOCALE_LANGUAGE_NEGOTIATION_USER] = array(
$providers[LANGUAGE_NEGOTIATION_USER] = array(
'callbacks' => array('language' => 'locale_language_from_user'),
'file' => $file,
'weight' => -4,
......@@ -501,7 +501,7 @@ function locale_language_negotiation_info() {
'description' => t("Follow the user's language preference."),
);
$providers[LOCALE_LANGUAGE_NEGOTIATION_BROWSER] = array(
$providers[LANGUAGE_NEGOTIATION_BROWSER] = array(
'callbacks' => array('language' => 'locale_language_from_browser'),
'file' => $file,
'weight' => -2,
......@@ -510,7 +510,7 @@ function locale_language_negotiation_info() {
'description' => t("Determine the language from the browser's language settings."),
);
$providers[LOCALE_LANGUAGE_NEGOTIATION_INTERFACE] = array(
$providers[LANGUAGE_NEGOTIATION_INTERFACE] = array(
'types' => array(LANGUAGE_TYPE_CONTENT),
'callbacks' => array('language' => 'locale_language_from_interface'),
'file' => $file,
......@@ -519,7 +519,7 @@ function locale_language_negotiation_info() {
'description' => t('Use the detected interface language.'),
);
$providers[LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK] = array(
$providers[LANGUAGE_NEGOTIATION_URL_FALLBACK] = array(
'types' => array(LANGUAGE_TYPE_URL),
'callbacks' => array('language' => 'locale_language_url_fallback'),
'file' => $file,
......
......@@ -1134,7 +1134,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
variable_set('language_negotiation_' . LANGUAGE_TYPE_URL, locale_language_negotiation_info());
// Change language providers settings.
variable_set('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX);
variable_set('locale_language_negotiation_url_part', LANGUAGE_NEGOTIATION_URL_PREFIX);
variable_set('locale_language_negotiation_session_param', TRUE);
// Uninstall Locale.
......@@ -2059,7 +2059,7 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
$tests = array(
// Default, browser preference should have no influence.
array(
'language_negotiation' => array(LOCALE_LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_DEFAULT),
'language_negotiation' => array(LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_DEFAULT),
'path' => 'admin/config',
'expect' => $default_string,
'expected_provider' => LANGUAGE_NEGOTIATION_DEFAULT,
......@@ -2068,34 +2068,34 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
),
// Language prefix.
array(
'language_negotiation' => array(LOCALE_LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_DEFAULT),
'language_negotiation' => array(LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_DEFAULT),
'path' => "$langcode/admin/config",
'expect' => $language_string,
'expected_provider' => LOCALE_LANGUAGE_NEGOTIATION_URL,
'expected_provider' => LANGUAGE_NEGOTIATION_URL,
'http_header' => $http_header_browser_fallback,
'message' => 'URL (PATH) > DEFAULT: with language prefix, UI language is switched based on path prefix',
),
// Default, go by browser preference.
array(
'language_negotiation' => array(LOCALE_LANGUAGE_NEGOTIATION_URL, LOCALE_LANGUAGE_NEGOTIATION_BROWSER),
'language_negotiation' => array(LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_BROWSER),
'path' => 'admin/config',
'expect' => $language_browser_fallback_string,
'expected_provider' => LOCALE_LANGUAGE_NEGOTIATION_BROWSER,
'expected_provider' => LANGUAGE_NEGOTIATION_BROWSER,
'http_header' => $http_header_browser_fallback,
'message' => 'URL (PATH) > BROWSER: no language prefix, UI language is determined by browser language preference',
),
// Prefix, switch to the language.
array(
'language_negotiation' => array(LOCALE_LANGUAGE_NEGOTIATION_URL, LOCALE_LANGUAGE_NEGOTIATION_BROWSER),
'language_negotiation' => array(LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_BROWSER),
'path' => "$langcode/admin/config",
'expect' => $language_string,
'expected_provider' => LOCALE_LANGUAGE_NEGOTIATION_URL,
'expected_provider' => LANGUAGE_NEGOTIATION_URL,
'http_header' => $http_header_browser_fallback,
'message' => 'URL (PATH) > BROWSER: with langage prefix, UI language is based on path prefix',
),
// Default, browser language preference is not one of site's lang.
array(
'language_negotiation' => array(LOCALE_LANGUAGE_NEGOTIATION_URL, LOCALE_LANGUAGE_NEGOTIATION_BROWSER, LANGUAGE_NEGOTIATION_DEFAULT),
'language_negotiation' => array(LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_BROWSER, LANGUAGE_NEGOTIATION_DEFAULT),
'path' => 'admin/config',
'expect' => $default_string,
'expected_provider' => LANGUAGE_NEGOTIATION_DEFAULT,
......@@ -2122,8 +2122,8 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
$tests = array(
// Default domain, browser preference should have no influence.
array(
'language_negotiation' => array(LOCALE_LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_DEFAULT),
'locale_language_negotiation_url_part' => LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN,
'language_negotiation' => array(LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_DEFAULT),
'locale_language_negotiation_url_part' => LANGUAGE_NEGOTIATION_URL_DOMAIN,
'path' => 'admin/config',
'expect' => $default_string,
'expected_provider' => LANGUAGE_NEGOTIATION_DEFAULT,
......@@ -2133,12 +2133,12 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
// Language domain specific URL, we set the $_SERVER['HTTP_HOST'] in
// locale_test.module hook_boot() to simulate this.
array(
'language_negotiation' => array(LOCALE_LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_DEFAULT),
'locale_language_negotiation_url_part' => LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN,
'language_negotiation' => array(LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_DEFAULT),
'locale_language_negotiation_url_part' => LANGUAGE_NEGOTIATION_URL_DOMAIN,
'locale_test_domain' => $language_domain,
'path' => 'admin/config',
'expect' => $language_string,
'expected_provider' => LOCALE_LANGUAGE_NEGOTIATION_URL,
'expected_provider' => LANGUAGE_NEGOTIATION_URL,
'http_header' => $http_header_browser_fallback,
'message' => 'URL (DOMAIN) > DEFAULT: domain example.cn should switch to Chinese',
),
......@@ -2381,7 +2381,7 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
$this->assertTrue($assert, t('Field language correctly changed.'));
// Enable content language URL detection.
language_negotiation_set(LANGUAGE_TYPE_CONTENT, array(LOCALE_LANGUAGE_NEGOTIATION_URL => 0));
language_negotiation_set(LANGUAGE_TYPE_CONTENT, array(LANGUAGE_NEGOTIATION_URL => 0));
// Test multilingual field language fallback logic.
$this->drupalGet("it/node/$node->nid");
......@@ -2628,7 +2628,7 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
// Enable some core and custom language providers. The test language type is
// supposed to be configurable.
$test_type = 'test_language_type';
$provider = LOCALE_LANGUAGE_NEGOTIATION_INTERFACE;
$provider = LANGUAGE_NEGOTIATION_INTERFACE;
$test_provider = 'test_language_provider';
$form_field = $type . '[enabled]['. $provider .']';
$edit = array(
......
......@@ -85,7 +85,7 @@ function locale_test_language_negotiation_info() {
*/
function locale_test_language_negotiation_info_alter(array &$language_providers) {
if (variable_get('locale_test_language_negotiation_info_alter', FALSE)) {
unset($language_providers[LOCALE_LANGUAGE_NEGOTIATION_INTERFACE]);
unset($language_providers[LANGUAGE_NEGOTIATION_INTERFACE]);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment