I maintain project dropdown_language. An issue has been brought to me #2886977: Block should use deriver when using getLanguageSwitchLinks regarding the alteration of dropbutton.

As i can best trace (comment 15) it seems links which are passes as the URL class object not being processing route_name to render href's but using URI which (i think) is producting the same path for each link once reprocessed.

CommentFileSizeAuthor
#5 2901106-5.patch4.11 KBmarkhalliwell

Comments

SKAUGHT created an issue. See original summary.

lor’s picture

I meet exactly the same problem with Bootstrap / Dropdown language.
This tips didn't work for me.
https://www.drupal.org/project/dropdown_language/issues/2886977#comment-...

Could you please do something about it?

Thank you !

markhalliwell’s picture

Title: rewriting of core dropbutton causing incorrect links from contribute modules. » Dropbutton links do not contain proper language

I pretty sure this is a combination of both Dropdown Language and Bootstrap.

According to https://drupal.stackexchange.com/questions/195545/custom-language-switch..., Dropdown Language should be using a deriver, which it's currently not. See:

\Drupal\language\Plugin\Block\LanguageBlock
\Drupal\language\Plugin\Derivative\LanguageBlock

It could even be a semi-core bug in \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl::getLanguageSwitchLinks perhaps?

All it does is clone the URL object, but it never sets the language on it (which may be handled by some deriver magic... I'm not sure).

Regardless, I think just checking for the language property in the link and then setting it on the Url object in the theme as a final backup should be enough.

I'll commit a fix shortly.

markhalliwell’s picture

Title: Dropbutton links do not contain proper language » Multilingual dropbutton links do not contain correct language identifier
markhalliwell’s picture

Status: Active » Fixed
StatusFileSize
new4.11 KB
sriman’s picture

Applied the patch given by markcarver & removed the below if condition in the BootstrapDropdown.php it works like a charm.

if (empty($element['url']->getOption('language'))) {
     $element['url']->setOption('language', $element['language']);
}

to

$element['url']->setOption('language', $element['language']);

skaught’s picture

#6: is there any reason you've removed the condition check? in my own testing, patch worked as expected.

markhalliwell’s picture

@sriman is coming from #2868100: Editing translations wrong redirect.

I'm not convinced removing the if statement is the right solution. It exists to ensure the theme doesn't override an explicitly set language option on a URL, which is coming from core/contrib.

  • markcarver committed 315fdb5 on 8.x-3.x
    Issue #2901106 by markcarver: Multilingual dropbutton links do not...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.