Problem/Motivation
On a multilingual site like Demo Umami, I want to display the link URL in the Cookie banner for Cookie documentation, Privacy policy, Imprint, in the same language as the one being displayed.
In the case of Demo Umami, when I click on the cookie documentation link in the Cookie banner on the Spanish page, I will be redirected to the English page, which is the default language of the site.
If I set the link destination of the cookie documentation to /node/[nid], the link destination will be a URL in the same language as the one being displayed.
However, I would like to display URLs defined in the module's routing.yml and Path alias URLs in the same way.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3249606-6.patch | 793 bytes | gresko8 |
| #5 | 3249606-5.patch | 776 bytes | kazuko.murata |
Issue fork cookies-3249606
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
anybody@kazuko.murata thank you.
Do I get you right, if you use /node/[nid] then the link is correctly delivered in the expected languages?
Please try to create Drupal custom menu items for the requests here:
What are the results for menu items? How does Drupal handle this? I guess that's a good reference we should use in COOKiES.
Comment #3
kazuko.murata commented@Anybody thank you.
Yes. If I use /node/[nid], I can be taken to the page in the expected language.
For example, if the default language of the site is English, and I register /node/6 in the Privacy uri, the link will be displayed as /node/6 on English pages, and /es/node/6 on Spanish pages.
The menu item can go to the page in the expected language.
The link of the menu item seems to be controlled by the link field type (core/modules/link/src/Plugin/Field/FieldType/LinkItem.php).
Comment #4
anybody@kazuko.murata Tanks? So are menu and COOKiES behaving equally or different?
Comment #5
kazuko.murata commented@Anybody
The behavior of menu and COOKiES is different.
The most minimal fix is
I suppose that this issue can be solved by adding a process like the attached patch.
Could you please check this?
Comment #6
gresko8 commentedThe problem is that cookie banner links are only pointing to the correct language version if they are node urls. The patch in comment #5 did not work for me. I have created a patch that rewrites all paths and serves the correct language version.
Comment #7
anybodyJust an idea: Couldn't we use the same logic as custom menu items or link fields for example? They are well tested...
Perhaps something like this:
If we want to ensure it's always an internal path starting with / we could add something like this to the validation:
I think @JFeltkamp should add his two cent what we'd like to support in that field. For me relative URLs would be totally fine, but link field for example also has code to allow external URLs if we really want that!
Comment #8
anybodyComment #9
anybodyComment #10
kaszarobertWe have a multilanguage site where we use a URL prefix such as /en/article1 or /de/article1. The cookie documentation page by default does not put these language prefixes in this case. This means if someone opens /de/article1 and opens the cookie banner with #editCookieSettings and clicks to the documentation link /cookies/documentation, the visitor will be redirected to the default English language version, in our case to /en/cookies/documentation even though he visited a German page.
With patch #6 now everything works fine. Even on the latest 2.0.0-alpha5.
Comment #11
anybodyPlease use a MR instead of patches, thank you!