summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/field/field.multilingual.inc4
-rw-r--r--modules/locale/locale.admin.inc7
-rw-r--r--modules/locale/locale.api.php5
-rw-r--r--modules/locale/locale.install7
-rw-r--r--modules/locale/locale.module35
-rw-r--r--modules/locale/locale.test25
-rw-r--r--modules/node/node.module46
-rw-r--r--modules/translation/translation.module4
8 files changed, 51 insertions, 82 deletions
diff --git a/modules/field/field.multilingual.inc b/modules/field/field.multilingual.inc
index f976bbe44..11e89b29b 100644
--- a/modules/field/field.multilingual.inc
+++ b/modules/field/field.multilingual.inc
@@ -132,8 +132,8 @@ function field_multilingual_valid_language($langcode, $default = TRUE) {
if (in_array($langcode, $enabled_languages)) {
return $langcode;
}
- global $language;
- $langcode = $default ? language_default('language') : $language->language;
+ global $language_content;
+ $langcode = $default ? language_default('language') : $language_content->language;
if (in_array($langcode, $enabled_languages)) {
return $langcode;
}
diff --git a/modules/locale/locale.admin.inc b/modules/locale/locale.admin.inc
index c9fbe8bd7..f93883866 100644
--- a/modules/locale/locale.admin.inc
+++ b/modules/locale/locale.admin.inc
@@ -479,7 +479,7 @@ function locale_languages_configure_form() {
$form = array(
'#submit' => array('locale_languages_configure_form_submit'),
'#theme' => 'locale_languages_configure_form',
- '#language_types' => language_types_configurable(),
+ '#language_types' => language_types_configurable(FALSE),
'#language_types_info' => language_types_info(),
'#language_providers' => language_negotiation_info(),
);
@@ -504,7 +504,7 @@ function _locale_languages_configure_form_language_table(&$form, $type) {
$info = $form['#language_types_info'][$type];
$table_form = array(
- '#title' => t('@type', array('@type' => $info['name'])),
+ '#title' => t('@type language detection', array('@type' => $info['name'])),
'#tree' => TRUE,
'#description' => $info['description'],
'#language_providers' => array(),
@@ -667,9 +667,10 @@ function locale_languages_configure_form_submit($form, &$form_state) {
if (isset($info['fixed'])) {
$language_types[$type] = FALSE;
$negotiation = array();
- foreach ($info['fixed'] as $id) {
+ foreach ($info['fixed'] as $weight => $id) {
if (isset($defined_providers[$id])) {
$negotiation[$id] = $defined_providers[$id];
+ $negotiation[$id]['weight'] = $weight;
}
}
language_negotiation_set($type, $negotiation);
diff --git a/modules/locale/locale.api.php b/modules/locale/locale.api.php
index 6f6504f4b..90f6132dd 100644
--- a/modules/locale/locale.api.php
+++ b/modules/locale/locale.api.php
@@ -57,6 +57,8 @@ function hook_language_switch_links_alter(array &$links, $type, $path) {
* the following key-value pairs:
* - "name": The human-readable language type identifier.
* - "description": A description of the language type.
+ * - "fixed": An array of language provider identifiers. Defining this key
+ * makes the language type non-configurable.
*/
function hook_language_types_info() {
return array(
@@ -64,6 +66,9 @@ function hook_language_types_info() {
'name' => t('Custom language'),
'description' => t('A custom language type.'),
),
+ 'fixed_custom_language_type' => array(
+ 'fixed' => array('custom_language_provider'),
+ ),
);
}
diff --git a/modules/locale/locale.install b/modules/locale/locale.install
index 93c0eb6dc..50f9605d5 100644
--- a/modules/locale/locale.install
+++ b/modules/locale/locale.install
@@ -70,10 +70,9 @@ function locale_update_7001() {
break;
}
- // Save new language negotiation options: UI language is tied to content
- // language as this was Drupal 6 behavior.
- language_negotiation_set(LANGUAGE_TYPE_CONTENT, array_flip($negotiation));
- language_negotiation_set(LANGUAGE_TYPE_INTERFACE, array(LOCALE_LANGUAGE_NEGOTIATION_CONTENT => 0));
+ // Save new language negotiation options.
+ language_negotiation_set(LANGUAGE_TYPE_INTERFACE, array_flip($negotiation));
+ language_negotiation_set(LANGUAGE_TYPE_CONTENT, array(LOCALE_LANGUAGE_NEGOTIATION_INTERFACE => 0));
language_negotiation_set(LANGUAGE_TYPE_URL, array(LOCALE_LANGUAGE_NEGOTIATION_URL => 0));
// Unset the old language negotiation system variable.
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index b091f12af..906aaf4c6 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -24,9 +24,9 @@ define('LOCALE_LANGUAGE_NEGOTIATION_URL', 'locale-url');
define('LOCALE_LANGUAGE_NEGOTIATION_BROWSER', 'locale-browser');
/**
- * The language is determined using the current content language.
+ * The language is determined using the current interface language.
*/
-define('LOCALE_LANGUAGE_NEGOTIATION_CONTENT', 'locale-content');
+define('LOCALE_LANGUAGE_NEGOTIATION_INTERFACE', 'locale-interface');
/**
* The language is set based on the user language settings.
@@ -69,7 +69,7 @@ function locale_help($path, $arg) {
case 'admin/config/regional/language/add':
return '<p>' . t('Add a language to be supported by your site. If your desired language is not available in the <em>Language name</em> drop-down, click <em>Custom language</em> and provide a language code and other details manually. When providing a language code manually, be sure to enter a standardized language code, since this code may be used by browsers to determine an appropriate display language.') . '</p>';
case 'admin/config/regional/language/configure':
- $output = '<p>' . t("Define how to decide which language is used to display content (text that you create and edit) and user interface text (text provided by Drupal and modules, such as field labels and help text). This decision is made by evaluating a series of detection methods for languages; the first detection method that gets a result will determine which language is used for that type of text. Define the order of evaluation of language detection methods on this page.") . '</p>';
+ $output = '<p>' . t("Define how to decide which language is used to display page elements (primarily text provided by Drupal and modules, such as field labels and help text). This decision is made by evaluating a series of detection methods for languages; the first detection method that gets a result will determine which language is used for that type of text. Define the order of evaluation of language detection methods on this page.") . '</p>';
return $output;
case 'admin/config/regional/language/configure/session':
$output = '<p>' . t('Determine the language from a request/session parameter. Example: "http://example.com?language=de" sets language to German based on the use of "de" within the "language" parameter.') . '</p>';
@@ -466,17 +466,26 @@ function locale_entity_info_alter(&$entity_info) {
/**
* Implements hook_language_types_info().
+ *
+ * Defines the three core language types:
+ * - Interface language is the only configurable language type in core. It is
+ * used by t() as the default language if none is specified.
+ * - Content language is by default non-configurable and inherits the interface
+ * language negotiated value. It is used by the Field API to determine the
+ * display language for fields if no explicit value is specified.
+ * - URL language is by default non-configurable and is determined through the
+ * URL language provider. It is used by l() as the default language if none is
+ * specified.
*/
function locale_language_types_info() {
return array(
- LANGUAGE_TYPE_CONTENT => array(
- 'name' => t('Content language detection'),
- 'description' => t('Order of language detection methods for content. If a version of content is available in the detected language, it will be displayed.'),
- ),
LANGUAGE_TYPE_INTERFACE => array(
- 'name' => t('User interface text language detection'),
+ 'name' => t('User interface text'),
'description' => t('Order of language detection methods for user interface text. If a translation of user interface text is available in the detected language, it will be displayed.'),
),
+ LANGUAGE_TYPE_CONTENT => array(
+ 'fixed' => array(LOCALE_LANGUAGE_NEGOTIATION_INTERFACE),
+ ),
LANGUAGE_TYPE_URL => array(
'fixed' => array(LOCALE_LANGUAGE_NEGOTIATION_URL),
),
@@ -534,13 +543,13 @@ function locale_language_negotiation_info() {
'description' => t("Determine the language from the browser's language settings."),
);
- $providers[LOCALE_LANGUAGE_NEGOTIATION_CONTENT] = array(
- 'types' => array(LANGUAGE_TYPE_INTERFACE),
- 'callbacks' => array('language' => 'locale_language_from_content'),
+ $providers[LOCALE_LANGUAGE_NEGOTIATION_INTERFACE] = array(
+ 'types' => array(LANGUAGE_TYPE_CONTENT),
+ 'callbacks' => array('language' => 'locale_language_from_interface'),
'file' => $file,
'weight' => 8,
- 'name' => t('Content'),
- 'description' => t('Use the detected content language.'),
+ 'name' => t('Interface'),
+ 'description' => t('Use the detected interface language.'),
);
return $providers;
diff --git a/modules/locale/locale.test b/modules/locale/locale.test
index 33fc3ab4a..3b605672a 100644
--- a/modules/locale/locale.test
+++ b/modules/locale/locale.test
@@ -965,11 +965,11 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
/**
* The default language set for the UI before uninstall.
*/
- protected $language_interface;
+ protected $language;
function setUp() {
parent::setUp('locale');
- $this->language_interface = 'en';
+ $this->language = 'en';
}
/**
@@ -980,12 +980,12 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
// Add a new language and optionally set it as default.
require_once DRUPAL_ROOT . '/includes/locale.inc';
- locale_add_language('fr', 'French', 'Français', LANGUAGE_LTR, '', '', TRUE, $this->language_interface == 'fr');
+ locale_add_language('fr', 'French', 'Français', LANGUAGE_LTR, '', '', TRUE, $this->language == 'fr');
// Check the UI language.
drupal_language_initialize();
- global $language_interface;
- $this->assertEqual($language_interface->language, $this->language_interface, t('Current language: %lang', array('%lang' => $language_interface->language)));
+ global $language;
+ $this->assertEqual($language->language, $this->language, t('Current language: %lang', array('%lang' => $language->language)));
// Enable multilingual workflow option for articles.
variable_set('language_content_type_article', 1);
@@ -1031,7 +1031,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
// Check the init language logic.
drupal_language_initialize();
- $this->assertEqual($language_interface->language, 'en', t('Language after uninstall: %lang', array('%lang' => $language_interface->language)));
+ $this->assertEqual($language->language, 'en', t('Language after uninstall: %lang', array('%lang' => $language->language)));
// Check JavaScript files deletion.
$this->assertTrue($result = !file_exists($js_file), t('JavaScript file deleted: %file', array('%file' => $result ? $js_file : t('found'))));
@@ -1091,7 +1091,7 @@ class LocaleUninstallFrenchFunctionalTest extends LocaleUninstallFunctionalTest
function setUp() {
parent::setUp();
- $this->language_interface = 'fr';
+ $this->language = 'fr';
}
}
@@ -1122,8 +1122,9 @@ class LanguageSwitchingFunctionalTest extends DrupalWebTestCase {
*/
function testLanguageBlock() {
// Enable the language switching block.
+ $language_type = LANGUAGE_TYPE_INTERFACE;
$edit = array(
- 'locale_language[region]' => 'sidebar_first',
+ "locale_{$language_type}[region]" => 'sidebar_first',
);
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
@@ -1136,14 +1137,14 @@ class LanguageSwitchingFunctionalTest extends DrupalWebTestCase {
// Set language negotiation.
drupal_load('module', 'locale');
include_once DRUPAL_ROOT . '/includes/language.inc';
- language_negotiation_set(LANGUAGE_TYPE_CONTENT, locale_language_negotiation_info());
+ language_negotiation_set($language_type, locale_language_negotiation_info());
// Assert that the language switching block is displayed on the frontpage.
$this->drupalGet('');
$this->assertText(t('Languages'), t('Language switcher block found.'));
// Assert that only the current language is marked as active.
- list($language_switcher) = $this->xpath('//div[@id="block-locale-language"]/div[@class="content"]');
+ list($language_switcher) = $this->xpath("//div[@id=\"block-locale-{$language_type}\"]/div[@class=\"content\"]");
$links = array(
'active' => array(),
'inactive' => array(),
@@ -1815,9 +1816,9 @@ class LocalizeDateFormatsFunctionalTest extends DrupalWebTestCase {
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
// Set language negotiation.
+ $language_type = LANGUAGE_TYPE_INTERFACE;
$edit = array(
- 'language[enabled][locale-url]' => TRUE,
- 'language_interface[enabled][locale-url]' => TRUE,
+ "{$language_type}[enabled][locale-url]" => TRUE,
);
$this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
diff --git a/modules/node/node.module b/modules/node/node.module
index 2d7464872..63908a3ce 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -1291,52 +1291,6 @@ function node_build_content($node, $view_mode = 'full') {
}
/**
- * Implements hook_language_negotiation_info().
- */
-function node_language_negotiation_info() {
- $providers = array();
-
- $providers['node-language'] = array(
- 'types' => array(LANGUAGE_TYPE_CONTENT),
- 'callbacks' => array('language' => 'node_language_provider'),
- 'file' => drupal_get_path('module', 'node') . '/node.module',
- 'name' => t('Content'),
- 'description' => t('Use the language of the displayed content.'),
- );
-
- return $providers;
-}
-
-/**
- * Return the language of the current node.
- *
- * @param $languages
- * An array of valid language objects.
- *
- * @return
- * A valid language code on success, FALSE otherwise.
- */
-function node_language_provider($languages) {
- require_once DRUPAL_ROOT . '/' . variable_get('path_inc', 'includes/path.inc');
-
- $path = isset($_GET['q']) ? $_GET['q'] : '';
- list($language, $path) = language_url_split_prefix($path, $languages);
- $language = $language ? $language : language_default();
- $path = drupal_get_normal_path($path, $language->language);
-
- // We cannot use args now.
- $path = explode('/', $path);
- // Act only if we are in a node page.
- if (isset($path[0]) && isset($path[1]) && $path[0] == 'node' && $nid = intval($path[1])) {
- // We cannot perform a node load here.
- $result = db_query('SELECT n.language FROM {node} n WHERE n.nid = :nid', array(':nid' => $nid))->fetchAssoc();
- return $result['language'];
- }
-
- return FALSE;
-}
-
-/**
* Generate an array which displays a node detail page.
*
* @param $node
diff --git a/modules/translation/translation.module b/modules/translation/translation.module
index b1348c948..531555912 100644
--- a/modules/translation/translation.module
+++ b/modules/translation/translation.module
@@ -182,7 +182,7 @@ function translation_form_alter(&$form, &$form_state, $form_id) {
function translation_node_view($node, $view_mode) {
if (isset($node->tnid) && $translations = translation_node_get_translations($node->tnid)) {
$path = 'node/' . $node->nid;
- $links = language_negotiation_get_switch_links(LANGUAGE_TYPE_CONTENT, $path);
+ $links = language_negotiation_get_switch_links(LANGUAGE_TYPE_INTERFACE, $path);
if (is_object($links)) {
$links = $links->links;
// Do not show link to the same node.
@@ -440,7 +440,7 @@ function translation_path_get_translations($path) {
* Replaces links with pointers to translated versions of the content.
*/
function translation_language_switch_links_alter(array &$links, $type, $path) {
- if ($type == LANGUAGE_TYPE_CONTENT && $paths = translation_path_get_translations($path)) {
+ if ($type == LANGUAGE_TYPE_INTERFACE && $paths = translation_path_get_translations($path)) {
foreach ($links as $langcode => $link) {
if (isset($paths[$langcode])) {
// Translation in a different node.