diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 1cd89a8..a2d1bac 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -42,9 +42,9 @@ function language_help($path, $arg) { return $output; case 'admin/config/regional/language/detection/selected': - $output = '

' . t("Determine which language is used to display page elements (primarily text provided by Drupal and modules, such as field labels and help text), from a selected language or the site's default language.") . '

'; - $output = $output . '

' . t("Selecting a different language here is preferred over changing your site's default language directly. Changing the site's default language can cause undesired side effects. A lot of things don't have language selectors. When you go add a view or contact form or specify the site name, there is no language selector, so Drupal can only assume you create all of those in the site's default language. If the site default langague is then switched, all the data entered earlier is now assumed to be in another language. Selecting a language here can avoid those problems.") . '

'; - $output = $output . '

' . t("Alternatively, change your site's default language directly when you need the change to ripple down through everything, for example in content creation forms if a content type or vocabulary is set to default to the site default language.", array('@default-lang-configuration' => url('admin/config/regional/language'))) . '

'; + $output = '

' . t('Changing the selected language here (and leaving this option as the last among the detection and selection options) is the easiest way to change the fallback language for the website, if you need to change how your site works by default (eg. when using an empty path prefix or using the default domain). Changing the site\'s default language itself might have other undesired side effects. +', array('@admin-change-language' => url('admin/config/regional/language'))) . '

'; + return $output; case 'admin/structure/block/manage/%/%': diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install index 4970242..c8777d4 100644 --- a/core/modules/locale/locale.install +++ b/core/modules/locale/locale.install @@ -732,6 +732,28 @@ function locale_update_8011() { } /** + * Renames language_default language negotiation method to language_selected. + */ +function locale_update_8013() { + $weight = update_variable_get('language_negotiation_methods_weight_language_interface', NULL); + if ($weight !== NULL) { + $weight[LANGUAGE_NEGOTIATION_SELECTED] = $weight['language-default']; + unset($weight['language-default']); + update_variable_set('language_negotiation_methods_weight_language_interface', $weight); + } + + $negotiation_interface = update_variable_get('language_negotiation_language_interface', NULL); + if ($negotiation_interface !== NULL) { + if (isset($negotiation_interface['language-default'])) { + $negotiation_interface[LANGUAGE_NEGOTIATION_SELECTED] = $negotiation_interface['language-default']; + $negotiation_interface[LANGUAGE_NEGOTIATION_SELECTED]['callbacks']['negotiation'] = 'language_from_selected'; + unset($negotiation_interface['language-default']); + update_variable_set('language_negotiation_language_interface', $negotiation_interface); + } + } +} + +/** * @} End of "addtogroup updates-7.x-to-8.x". * The next series of updates should start at 9000. */ diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php index 7a30cb0..65c30de 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php @@ -106,12 +106,18 @@ class LanguageUpgradePathTest extends UpgradePathTestBase { 'language-session' => '-6', 'language-user' => '-4', 'language-browser' => '-2', - 'language-default' => '10', + 'language-selected' => '10', ); // Check that locale_language_providers_weight_language is correctly // renamed. $current_weights = update_variable_get('language_negotiation_methods_weight_language_interface', array()); $this->assertTrue(serialize($expected_weights) == serialize($current_weights), t('Language negotiation method weights upgraded.')); + $this->assertTrue(isset($current_weights['language-selected']), 'Language-selected is present.'); + $this->assertFalse(isset($current_weights['language-default']), 'Language-default is not present.'); + + // Check that negotiation callback was added to language_negotiation_language_interface. + $language_negotiation_language_interface = update_variable_get('language_negotiation_language_interface', NULL); + $this->assertTrue(isset($language_negotiation_language_interface[LANGUAGE_NEGOTIATION_SELECTED]['callbacks']['negotiation']), 'Negotiation callback was added to language_negotiation_language_interface.'); // Look up migrated plural string. $source_string = db_query('SELECT * FROM {locales_source} WHERE lid = 22')->fetchObject();