Problem description
When having both Language and Domain (country) codes as part of the URL, the language module assumes the first code is the language code. My requirement is to have a URL syntax: /[domain]/[language]/some-page.
The Country Path outbound processor concatenates the $path variable. Other processors, like the Language URL, use the $options['prefix'] variable.
Proposed resolution
It looks like the LanguageNegotiationUrl class is adding/removing a prefix at/from the beginning of the URL. Changing the priority of the Domain inbound and outbound processor to have the CountryPath inbound processor acts first and the outbound processor acts last.
Use $options['prefix'] in the outbound processor.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | country_language-prefix-conflict-2790683-6.patch | 1.53 KB | sutharsan |
| #5 | interdiff-2790683-4-5.txt | 1.7 KB | sutharsan |
| #5 | country_language-prefix-conflict-2790683-5.patch | 1.67 KB | sutharsan |
| #5 | processor-priorities.png | 299.08 KB | sutharsan |
| #4 | country_language-prefix-conflict-2790683-4-D8.patch | 1.68 KB | jurcello |
Comments
Comment #2
jurcello commentedComment #3
jurcello commentedComment #4
jurcello commentedAnd now with a working patch.
Comment #5
sutharsan commentedI agree with changing the weight of the in and outbound processors. At least for the use case I need it for where the URL structure is

example.com/[country]/[language]/. See screenshot for the resulting weights.But I do not agree with this code:
I presume the purpose of this code is to prefix the
$options['prefix']to the$path. But that contradicts to the comment. Further combining the two is done in the calling code, for example in UrlGenerator::generateFromRoute. If you look at other processors, the path prefix is only put in $options['prefix'] (which is passed by reference). That is what I suggest for this processor to. Just place the country prefix before any of the existing prefixes. The priority will take care of the rest.In the attached patch, I also remove the assumption that language and the path will never start with the country code. But what is the country code is 'usa' and the original path is also 'usa'. (I know I should have opened a separate issue for this). The CountryPath outbound processor is only called once, so there is no risk of adding the same country code twice.
Comment #6
sutharsan commentedReworked the patch to be applied on top of #2790057: Path processor contains hardcoded domain_suffixes which causes non working code, as I need to apply both.
Comment #7
jurcello commentedYou are right with the prefix. The code looks much cleaner now.
Comment #9
itsekhmistro commentedHi everyone,
Thank you very much for the patch. Applied.
Comment #11
nijinanijil commentedIf country path is there in the url it always returns default language contents .
example.com/us/en/node/1
example.com/us/es/node/1
Both returns English version
Comment #12
johnpicozziI am having an issue where when accessing a path like example.com/apac/de I get redirected to example.com/apac. When looking at the code with Xdebug I see that $options['prefix'] isn't set correctly. If I update the code below manually to replace $options['prefix'] with de/ the site works perfectly.
$options['prefix'] = "$domain_suffix/" . $options['prefix'];Has anyone else had this issue? trying to find a solution for it.
Country Path - 8.x-1.0
Domain - 8.x-1.0-alpha11
Drupal 8.3.7
Comment #13
iyyappan.govindSame issue here also.
Comment #14
quadrexdevHi everyone,
Having the same issue as in #11.
Has anyone found the solution?