diff --git a/core/modules/language/src/Form/NegotiationUrlForm.php b/core/modules/language/src/Form/NegotiationUrlForm.php index f28a53d1a611f1e155335681401062fc5ba1f3df..eed7a38263b1b4c4d5e373467843deda36a4b989 100644 --- a/core/modules/language/src/Form/NegotiationUrlForm.php +++ b/core/modules/language/src/Form/NegotiationUrlForm.php @@ -59,7 +59,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#tree' => TRUE, '#title' => $this->t('Domain configuration'), '#open' => TRUE, - '#description' => $this->t('The domain names to use for these languages. Leave blank for the default language. Use with caution in a production environment.<strong>Modifying this value may break existing URLs. Use with caution in a production environment.</strong> Example: Specifying "de.example.com" as language domain for German will result in an URL like "http://de.example.com/contact".'), + '#description' => $this->t('The domain names to use for these languages. <strong>Modifying this value may break existing URLs. Use with caution in a production environment.</strong> Example: Specifying "de.example.com" as language domain for German will result in an URL like "http://de.example.com/contact".'), '#states' => array( 'visible' => array( ':input[name="language_negotiation_url_part"]' => array( @@ -130,10 +130,10 @@ public function validateForm(array &$form, FormStateInterface $form_state) { $value = $form_state->getValue(array('domain', $langcode)); if ($value === '') { - if (!$language->isDefault() && $form_state->getValue('language_negotiation_url_part') == LanguageNegotiationUrl::CONFIG_DOMAIN) { + if ($form_state->getValue('language_negotiation_url_part') == LanguageNegotiationUrl::CONFIG_DOMAIN) { // Throw a form error if the domain is blank for a non-default language, // although it is required for selected negotiation type. - $form_state->setErrorByName("domain][$langcode", $this->t('The domain may only be left blank for the default language.')); + $form_state->setErrorByName("domain][$langcode", $this->t('The domain may not be left blank for %language.', array('%language' => $language->name))); } } elseif (isset($count[$value]) && $count[$value] > 1) { diff --git a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php index b1d40c0d4a4af9bf6e9744624d24c618108669fd..6a81438e8a15472bc9abda7481c2cdea7ae691d4 100644 --- a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php @@ -403,12 +403,23 @@ function testLanguageDomain() { ); $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); + // Do not allow blank domain. + $edit = array( + 'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN, + 'domain[en]' => '', + ); + $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration')); + $this->assertText('The domain may not be left blank for English', 'The form does not allow blank domains.'); + $this->rebuildContainer(); + // Change the domain for the Italian language. $edit = array( 'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN, + 'domain[en]' => gethostname(), 'domain[it]' => 'it.example.com', ); $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration')); + $this->assertText('The configuration options have been saved', 'Domain configuration is saved.'); $this->rebuildContainer(); // Build the link we're going to test. diff --git a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php b/core/modules/language/src/Tests/LanguageUrlRewritingTest.php index ca3d93511ef06f7c70b0e09816dfa0662ff637e8..0d4c2cef0b65875c0744ba40c477fa2af007d069 100644 --- a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php +++ b/core/modules/language/src/Tests/LanguageUrlRewritingTest.php @@ -101,6 +101,7 @@ function testDomainNameNegotiationPort() { $language_domain = 'example.fr'; $edit = array( 'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN, + 'domain[en]' => gethostname(), 'domain[fr]' => $language_domain ); $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));