#780318 by plach: Fixed path prefixes are always active on multilingual sites.
parent
b6fd2cd427
commit
0614a78538
|
@ -6,6 +6,32 @@
|
|||
* Administration functions for locale.module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The language is determined using a URL language indicator:
|
||||
* path prefix or domain according to the configuration.
|
||||
*/
|
||||
define('LOCALE_LANGUAGE_NEGOTIATION_URL', 'locale-url');
|
||||
|
||||
/**
|
||||
* The language is set based on the browser language settings.
|
||||
*/
|
||||
define('LOCALE_LANGUAGE_NEGOTIATION_BROWSER', 'locale-browser');
|
||||
|
||||
/**
|
||||
* The language is determined using the current interface language.
|
||||
*/
|
||||
define('LOCALE_LANGUAGE_NEGOTIATION_INTERFACE', 'locale-interface');
|
||||
|
||||
/**
|
||||
* The language is set based on the user language settings.
|
||||
*/
|
||||
define('LOCALE_LANGUAGE_NEGOTIATION_USER', 'locale-user');
|
||||
|
||||
/**
|
||||
* The language is set based on the request/session parameters.
|
||||
*/
|
||||
define('LOCALE_LANGUAGE_NEGOTIATION_SESSION', 'locale-session');
|
||||
|
||||
/**
|
||||
* Regular expression pattern used to localize JavaScript strings.
|
||||
*/
|
||||
|
@ -156,6 +182,10 @@ function locale_language_from_session($languages) {
|
|||
function locale_language_from_url($languages) {
|
||||
$language_url = FALSE;
|
||||
|
||||
if (!language_negotiation_get_any(LOCALE_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:
|
||||
// $_GET['q'] might not be available at this time, because
|
||||
|
|
|
@ -12,32 +12,6 @@
|
|||
* Gettext portable object files are supported.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The language is determined using a URL language indicator:
|
||||
* path prefix or domain according to the configuration.
|
||||
*/
|
||||
define('LOCALE_LANGUAGE_NEGOTIATION_URL', 'locale-url');
|
||||
|
||||
/**
|
||||
* The language is set based on the browser language settings.
|
||||
*/
|
||||
define('LOCALE_LANGUAGE_NEGOTIATION_BROWSER', 'locale-browser');
|
||||
|
||||
/**
|
||||
* The language is determined using the current interface language.
|
||||
*/
|
||||
define('LOCALE_LANGUAGE_NEGOTIATION_INTERFACE', 'locale-interface');
|
||||
|
||||
/**
|
||||
* The language is set based on the user language settings.
|
||||
*/
|
||||
define('LOCALE_LANGUAGE_NEGOTIATION_USER', 'locale-user');
|
||||
|
||||
/**
|
||||
* The language is set based on the request/session parameters.
|
||||
*/
|
||||
define('LOCALE_LANGUAGE_NEGOTIATION_SESSION', 'locale-session');
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Hook implementations
|
||||
|
||||
|
@ -533,6 +507,7 @@ function locale_entity_info_alter(&$entity_info) {
|
|||
* specified.
|
||||
*/
|
||||
function locale_language_types_info() {
|
||||
require_once DRUPAL_ROOT . '/includes/locale.inc';
|
||||
return array(
|
||||
LANGUAGE_TYPE_INTERFACE => array(
|
||||
'name' => t('User interface text'),
|
||||
|
|
|
@ -1170,10 +1170,9 @@ class LocaleLanguageSwitchingFunctionalTest extends DrupalWebTestCase {
|
|||
);
|
||||
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
|
||||
|
||||
// Set language negotiation.
|
||||
drupal_load('module', 'locale');
|
||||
include_once DRUPAL_ROOT . '/includes/language.inc';
|
||||
language_negotiation_set($language_type, locale_language_negotiation_info());
|
||||
// Enable URL language detection and selection.
|
||||
$edit = array('language[enabled][locale-url]' => '1');
|
||||
$this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
|
||||
|
||||
// Assert that the language switching block is displayed on the frontpage.
|
||||
$this->drupalGet('');
|
||||
|
@ -1452,6 +1451,12 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
|
|||
);
|
||||
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
|
||||
|
||||
// Check that the "xx" front page is not available when path prefixes are
|
||||
// not enabled yet.
|
||||
$this->drupalPost('admin/config/regional/language/configure', array(), t('Save settings'));
|
||||
$this->drupalGet($prefix);
|
||||
$this->assertResponse(404, t('The "xx" front page is not available yet.'));
|
||||
|
||||
// Enable URL language detection and selection.
|
||||
$edit = array('language[enabled][locale-url]' => 1);
|
||||
$this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
|
||||
|
@ -1835,6 +1840,10 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
|
|||
require_once DRUPAL_ROOT . '/includes/locale.inc';
|
||||
locale_add_language('it', 'Italian', 'Italiano', LANGUAGE_LTR, '', '', TRUE, FALSE);
|
||||
|
||||
// Enable URL language detection and selection.
|
||||
$edit = array('language[enabled][locale-url]' => '1');
|
||||
$this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
|
||||
|
||||
// Set "Basic page" content type to use multilingual support.
|
||||
$edit = array(
|
||||
'language_content_type' => 1,
|
||||
|
|
Loading…
Reference in New Issue