diff --git a/core/modules/language/language.module b/core/modules/language/language.module index d4f6bf5..6901c91 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -63,7 +63,7 @@ function language_help($route_name, RouteMatchInterface $route_match) { return $output; case 'language.negotiation_browser': - $output = '

' . t('Browsers use different language codes to refer to the same languages. This language mapping list allows to match those to the languages used internally.', array('!configure-languages' => \Drupal::url('language.admin_overview'))) . '

'; + $output = '

' . t('Browsers use different language codes to refer to the same languages. Internally, a best effort is made to determine the correct language based on the code that the browser sends. You can add and edit additional mappings from browser language codes to site languages.', array('!configure-languages' => \Drupal::url('language.admin_overview'))) . '

'; return $output; case 'language.negotiation_selected': diff --git a/core/modules/language/src/Form/NegotiationBrowserDeleteForm.php b/core/modules/language/src/Form/NegotiationBrowserDeleteForm.php index 87fbfbd..2cf5a6c 100644 --- a/core/modules/language/src/Form/NegotiationBrowserDeleteForm.php +++ b/core/modules/language/src/Form/NegotiationBrowserDeleteForm.php @@ -65,7 +65,14 @@ public function submitForm(array &$form, FormStateInterface $form_state) { if (array_key_exists($this->browserLangcode, $mappings)) { unset($mappings[$this->browserLangcode]); language_set_browser_drupal_langcode_mappings($mappings); - drupal_set_message(t('The configuration options have been saved.')); + + $t_args = array( + '%browser' => $this->browserLangcode, + ); + + $this->logger('language')->notice('The browser language detection mapping for the %browser browser language code has been deleted.', $t_args); + + drupal_set_message(t('The mapping for the %browser browser language code has been deleted.', $t_args)); } $form_state->setRedirect('language.negotiation_browser'); diff --git a/core/modules/language/src/Form/NegotiationBrowserForm.php b/core/modules/language/src/Form/NegotiationBrowserForm.php index 8c4d76c..d4edfcc 100644 --- a/core/modules/language/src/Form/NegotiationBrowserForm.php +++ b/core/modules/language/src/Form/NegotiationBrowserForm.php @@ -117,14 +117,12 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'textfield', '#title' => $this->t('Browser language code'), '#description' => $this->t('Use language codes as defined by the W3C for interoperability. Examples: "en", "en-gb" and "zh-hant".', array('@w3ctags' => 'http://www.w3.org/International/articles/language-tags/')), - '#default_value' => '', '#size' => 20, ); $form['new_mapping']['drupal_langcode'] = array( '#type' => 'select', '#title' => $this->t('Site language'), '#options' => $language_options, - '#default_value' => '', ); return parent::buildForm($form, $form_state); @@ -138,7 +136,6 @@ public function validateForm(array &$form, FormStateInterface $form_state) { $unique_values = array(); // Check all mappings. - $mappings = array(); if ($form_state->hasValue('mappings')) { $mappings = $form_state->getValue('mappings'); foreach ($mappings as $key => $data) { @@ -179,7 +176,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $config->setData($mappings); $config->save(); } - $form_state->setRedirect('language.negotiation'); parent::submitForm($form, $form_state); } diff --git a/core/modules/language/src/Tests/LanguageBrowserDetectionUnitTest.php b/core/modules/language/src/Tests/LanguageBrowserDetectionUnitTest.php index 62ee8e3..f724338 100644 --- a/core/modules/language/src/Tests/LanguageBrowserDetectionUnitTest.php +++ b/core/modules/language/src/Tests/LanguageBrowserDetectionUnitTest.php @@ -186,6 +186,14 @@ function testUIBrowserLanguageMappings() { $edit = array(); $this->drupalPostForm('admin/config/regional/language/detection/browser/delete/' . $browser_langcode, $edit, t('Confirm')); + // We need raw here because %browser will add HTML. + $t_args = array( + '%browser' => $browser_langcode, + ); + $this->assertRaw(t('The mapping for the %browser browser language code has been deleted.', $t_args), 'The test browser language code has been deleted.'); + + // Check we went back to the browser negotiation mapping overview. + $this->assertUrl(\Drupal::url('language.negotiation_browser', [], ['absolute' => TRUE])); // Check that ch-zn no longer exists. $this->assertNoField('edit-mappings-zh-cn-browser-langcode', 'Chinese browser language code no longer exists.'); @@ -195,7 +203,7 @@ function testUIBrowserLanguageMappings() { 'new_mapping[drupal_langcode]' => 'en', ); $this->drupalPostForm('admin/config/regional/language/detection/browser', $edit, t('Save configuration')); - $this->drupalGet('admin/config/regional/language/detection/browser'); + $this->assertUrl(\Drupal::url('language.negotiation_browser', [], ['absolute' => TRUE])); $this->assertField('edit-mappings-xx-browser-langcode', 'xx', 'Browser language code found.'); $this->assertField('edit-mappings-xx-drupal-langcode', 'en', 'Drupal language code found.'); @@ -217,7 +225,7 @@ function testUIBrowserLanguageMappings() { 'mappings[xx][drupal_langcode]' => 'zh-hans', ); $this->drupalPostForm('admin/config/regional/language/detection/browser', $edit, t('Save configuration')); - $this->drupalGet('admin/config/regional/language/detection/browser'); + $this->assertUrl(\Drupal::url('language.negotiation_browser', [], ['absolute' => TRUE])); $this->assertField('edit-mappings-xx-browser-langcode', 'xx', 'Browser language code found.'); $this->assertField('edit-mappings-xx-drupal-langcode', 'zh-hans', 'Drupal language code found.'); }