- 🇨🇭Switzerland wengerk Lausanne
Do you use the standard Drupal language switcher or your own switcher ?
If you use the standard Drupal language switcher, do you have some error in your Console ?
- 🇩🇪Germany JorgeClayton
Thank you for your reply!
I'm using the standard language switcher for Drupal with no modificatons at all.
The block's name is " Language switcher (Content)".
Unfortunately there are no errors shown in the console, if you were referring to the one in dev tools. - 🇨🇭Switzerland wengerk Lausanne
I'll take a look when used with the default language switcher.
We use this module on 2 huge projects without any problems, but we use a custom approach as described in the README/Module description with our own JS. I think the default JS given by the module does not work anymore with the Drupal default language switcher, since Drupal changed the default language switcher when released Olivero.
If you want to fix it quicly, I suggest you to add a custom JS that triggered when clicking on the language link
// Prevent attempting to attach cookie if the common library is not available. if (typeof Drupal.homeRedirectLang == "undefined") { return; } # Change the selector here for your own class on <a> of language switcher. let links = document.querySelectorAll('.language-link'); links.forEach(link => { link.addEventListener('click', function (event) { var hreflang = event.target.getAttribute('hreflang'); Drupal.homeRedirectLang.setPreferredLanguage(hreflang); }); });
- 🇨🇭Switzerland wengerk Lausanne
I tested following your given steps in the issue summary and on my side, everythings works as intended. When I change my lang from any page (homepage or any other) then when navigating the Homepage I'm redirected to the last language I visit the website.
When you inspect your Cookies, you should see a Cookie nammed
home_redirect_lang_preferred_langcode
that should be filled with the last choosen language - does it works ?What are the language you enabled ? I tested with French (fr) and English (en). Maybe the module have an issue with some language, could you provide me the language you enabled on step "Enabled all modules of the multilingual section".
- 🇨🇭Switzerland wengerk Lausanne
I suspect that the cookie is not being set on your browser. ... And since you have activated the Fallback browser, you are constantly redirected to the language of your browser. On this production site https://shop.swisstopo.admin.ch, when you switch languages and navigate the site, then return to the homepage with https://shop.swisstopo.admin.ch, are you properly redirected to your last navigation language? If not, then it seems that your browser or an extension of it is preventing the home_redirect_lang_preferred_langcode cookie from being set.
- Status changed to Closed: cannot reproduce
6 months ago 7:40am 31 May 2024