Loading core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php +4 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,10 @@ public function processOutbound($path, &$options = [], Request $request = NULL, } $languages = array_flip(array_keys($this->languageManager->getLanguages())); // Language can be passed as an option, or we go for current URL language. if (!isset($options['language'])) { if (!isset($options['language']) || ($options['language'] instanceof LanguageInterface && in_array($options['language']->getId(), [ LanguageInterface::LANGCODE_NOT_SPECIFIED, LanguageInterface::LANGCODE_NOT_APPLICABLE, ]))) { $language_url = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL); $options['language'] = $language_url; } Loading core/modules/node/tests/src/Functional/NodeTranslationUITest.php +22 −0 Original line number Diff line number Diff line Loading @@ -577,4 +577,26 @@ public function testDetailsTitleIsNotEscaped() { $this->assertSession()->responseContains($markup); } /** * Test that when content is language neutral, it uses interface language. * * When language neutral content is displayed on interface language, it should * consider the interface language for creating the content link. */ public function testUrlPrefixOnLanguageNeutralContent() { $this->drupalLogin($this->administrator); $neutral_langcodes = [ LanguageInterface::LANGCODE_NOT_APPLICABLE, LanguageInterface::LANGCODE_NOT_SPECIFIED, ]; foreach ($neutral_langcodes as $langcode) { $article = $this->drupalCreateNode(['type' => 'article', 'langcode' => $langcode]); $this->drupalGet("{$this->langcodes[1]}/admin/content"); $this->assertSession()->linkByHrefExists("{$this->langcodes[1]}/node/{$article->id()}"); $this->drupalGet("{$this->langcodes[2]}/admin/content"); $this->assertSession()->linkByHrefExists("{$this->langcodes[2]}/node/{$article->id()}"); } } } Loading
core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php +4 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,10 @@ public function processOutbound($path, &$options = [], Request $request = NULL, } $languages = array_flip(array_keys($this->languageManager->getLanguages())); // Language can be passed as an option, or we go for current URL language. if (!isset($options['language'])) { if (!isset($options['language']) || ($options['language'] instanceof LanguageInterface && in_array($options['language']->getId(), [ LanguageInterface::LANGCODE_NOT_SPECIFIED, LanguageInterface::LANGCODE_NOT_APPLICABLE, ]))) { $language_url = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL); $options['language'] = $language_url; } Loading
core/modules/node/tests/src/Functional/NodeTranslationUITest.php +22 −0 Original line number Diff line number Diff line Loading @@ -577,4 +577,26 @@ public function testDetailsTitleIsNotEscaped() { $this->assertSession()->responseContains($markup); } /** * Test that when content is language neutral, it uses interface language. * * When language neutral content is displayed on interface language, it should * consider the interface language for creating the content link. */ public function testUrlPrefixOnLanguageNeutralContent() { $this->drupalLogin($this->administrator); $neutral_langcodes = [ LanguageInterface::LANGCODE_NOT_APPLICABLE, LanguageInterface::LANGCODE_NOT_SPECIFIED, ]; foreach ($neutral_langcodes as $langcode) { $article = $this->drupalCreateNode(['type' => 'article', 'langcode' => $langcode]); $this->drupalGet("{$this->langcodes[1]}/admin/content"); $this->assertSession()->linkByHrefExists("{$this->langcodes[1]}/node/{$article->id()}"); $this->drupalGet("{$this->langcodes[2]}/admin/content"); $this->assertSession()->linkByHrefExists("{$this->langcodes[2]}/node/{$article->id()}"); } } }