Drupal Version 8.9.16
Domain module 8.x-1.0-beta6
Actual Behavior
I think the multi-domain and multi-laguage/local is a big issue and people only doing english should consider the rest of the world and not only think all EN...
I have the issue, if I use domain detection it is ok for end-user but a nightmare to administer. I live in Switzerland, we have 4 national languages!
I don't find any good help about this. The client does not want:
www.example-fr.com for french
www.example-fr.com/de for german
www.example-fr.com/it for italian
Expected Behavior
The client wants only this:
www.example-fr.com for french
www.example-de.com for german
www.example-it.com for italian
but needs to be able to have a real administration, how to setup this?? thanks!
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 3222865-domain_language_detection-11.patch | 9.57 KB | agentrickard |
| #10 | 3222865-domain_language_detection-9.patch | 9.3 KB | agentrickard |
| #6 | 3222865-domain_language_detection.patch | 9.57 KB | agentrickard |
| #3 | Screen Shot 2021-07-20 at 10.03.30 AM.png | 68.31 KB | agentrickard |
Issue fork domain-3222865
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
seyfcom commentedComment #3
agentrickardPlease don't begin a support request by insulting the maintainer's intentions.
Language detection is a core feature of Drupal, and can be configured per-domain here -- admin/config/regional/language/detection/url -- but that method is incompatible with how Domain works.
You need to overwrite the `default_langcode` per domain, which should be available using Domain Config module. See the README.md file in that module.
You would need to enable the module and then provide a configuration file for each domain, something like so:
domain.config.[YOUR_FR_DOMAIN_ID].system.site.yml
domain.config.[YOUR_DE_DOMAIN_ID].system.site.yml
It is not necessary to reproduce the entire system.site file, as noted in the README.
You could also do this dynamically in settings.php if you don't want to enable Domain Config.
In this scenario, you would set the core Language detection settings to 'URL' and 'domain' and leave the form values empty on /admin/config/regional/language/detection/url
It is possible, however, that setting the default language in this way will have unintended side-effects. I simply don't have time to test all possible iterations, and need to rely on people who need these features to help provide solutions.
Comment #4
agentrickardIn my limited tests, that won't work either -- at least not for interface translation. I have not tested it with content translation.
We may need a new language negotiator that accepts an array (list) of domains.
Comment #5
agentrickardLooks like someone already wrote this -- https://www.drupal.org/project/domain_language_negotiation
Comment #6
agentrickardSo this turns out to be a fascinating problem. The baseline plugin is pretty solid. Here's a patch for that.
The problem, however, is the Language Switcher links, which are expecting each language to have a distinct URL. So if we have a case where two domains use the same language, it's not clear which site to send people to.
Since we cannot key by unique langcode, for now I added this comment, which should go in the README:
The attached patch needs testing by people with this use-case.
Comment #8
agentrickardCredit to @flyke for the original implementation.
Comment #10
agentrickardRemove the blank settings yml.
Comment #11
agentrickardTry again without the typo.
Comment #12
agentrickardTo test this patch:
- Download and apply the patch from the domain project root.
- Clear cache
- Enable languages as normal
- Go to admin/config/regional/language/detection
- Select Domain record as the detection method
- Go to admin/config/regional/language/detections/domain to configure default languages
- Test the behavior
Note that the "language switcher" block does not allow multiple links to use the same language, so you cannot use it. The "Domain navigation" block can be used instead.
Comment #13
shenzhuxi commentedI'm maintaining domain_path module and going through the chaos of domain and language for D8 to D9 update.
First thing first, disable the core content_translate module which will bring your trouble into another dimension when dealing with interface language and content language X multi languages.
For @seyfcom requirements, it's fairly easy and bug free now if the domain name and language relation was 1 <-> 1 (and only).
www.example-fr.com for french
www.example-de.com for german
www.example-it.com for italian
You just need to enable domain and language modules and don't need domain_lang.
After clean install and set up three domain names and three languages, go to admin/config/regional/language/detection and enable "Language from the URL (Path prefix or domain)". Then go to /admin/config/regional/language/detection/url and select Domain and put three domain names match three languages.
I didn't find bug so far to use domain_config after this setup.
For more compilated use case - each domain needs to support multi-languages and has different default language (you may also want the default language won't have a URL prefix) - you can't set up everything from the web UI.
Config editor from devel module may make your life easier.
Here are the steps:
1. clean install and enable domain, domain_config and language modules
2. set up domain names like domain1.com and domain2.com and languages like langA and LangB
3. go to /admin/config/regional/language/detection/selected and enable domain configuration. Create configurations like:
DOMAIN CONFIGURATION
Language: LangA
DOMAIN CONFIGURATION
Language: LangB
4. go to /devel/config and delete language.negotiation if you have it, so you can have different settings for different domain.
5. go to /devel/config and you should be able to see domain.config.domain1.language.negotiation and domain.domain2.ca.language.negotiation.
Change values (don't copy and paste to cover the whole config) like:
domain.config.domain1.language.negotiation ->
session:
parameter: language
url:
source: path_prefix
prefixes:
LangA: null
LangB: lang-b
selected_langcode: LangA
domain.domain2.ca.language.negotiation ->
session:
parameter: language
url:
source: path_prefix
prefixes:
LangA: lang-a
LangB: null
selected_langcode: LangB
After you set up it once, you can export all the config files for future use.
With this setup, I find that domain_config may be buggy to use certain domain specific config like the "Basic site settings". It seems because the absence of the global language.negotiation.
I also tested the patch. Please correct me if I'm wrong. I think we don't really need it for the first setup and for the second setup it won't help.
What we need is to alter the language module to allow each domain have different "default language" and flexible URL prefix.
Making domain_config working consistently in complicated domains and languages detections should be a separated issue.
Comment #15
jefuri commentedI found out where the issue lies. I am maintainer of the domain_language_negotiation module and had this issue as well. The problem lies in the caching of the configFactory. Because in a very early stage some inbound, outbound uses the language negotiation config from the main yml, because it is not possible yet to determine a domain and therefor a domain config override. The config factory will static cache it and in a later stage the domain config overrides will not be loaded again because of the static cache when the domain is available.
So the solution I have ready will handle 2 static caches to alter and update the overridden data in config the moment the domain is available.
Comment #17
agentrickard@jefuri
Do you think we can abandon this patch in favor of the other module? Or vice versa?
Comment #18
jefuri commentedNo, I think it should land in the domain module. The thing is that you cannot really override language settings on a domain level because the way Drupal needs the language on a very early stage. The Entity Type Manager it self needs it, and the Domain record is an entity, because of translation situations (maybe) in usage of the Entity Type Manager.
So ones the domain modules knows the language, whatever you do later on through domain config (in combination with language negotiation) does not matter anymore. The language is set.
So if you want to use the domain config module in some way to determine language negotiation, it should handle that information from the domain config overrides before the domain logic.
Comment #19
mmillford commentedI'm actually running into this problem now. The project in question uses Domain, and has a different language negotation per domain via domain_config (at least one uses a prefix for the non-default language, while another uses a different domain per language). Because the domain config and the language negotiation rules depend on each other, the site ends up using the default language negotation rather than the one for the domain, and ends up using the wrong language. The result is that some of the content is in the correct language, but mixed with config that wasn't translated.
domain1.com (english)
domain1.com/es (spanish)
domain2.com (english)
es.domain2.com (spanish)
Based on this thread, it seems like this approach may not be fully supported. Would the fix may be a custom language negotiator that doesn't use config, and thus doesn't cause the circular dependency? Although that may need to be implementation-specific at that point.
Comment #20
agentrickardRight. See also #3280884: Frontpage nodes changes randomly to other domain configured frontpage node which I'd like to get reproduced in a test case.
We do have tests for translated config, and they pass -- see domain_config/tests/src/Functional/DomainConfigOverriderTest.php and domain_config/tests/src/Functional/DomainConfigHomepageTest.php
It's *changing* language that seems to be the special case problem.
I agree that this should go in the main module. The real question becomes how to avoid the loop that @jefuri points out in #18.
It may be that we have to tell people: the only way to override language per domain is via settings.php, since that wouldn't require entity / database lookups.
I think that's an acceptable answer, so long as we can support it.
The first step is writing a test that can reproduce the issue.
Comment #21
bsnodgrass commentedReviewing for #3366588: Documentation for 2.0.x
Changing component to code, should Version be updated to 2.0.x?
Comment #22
mably commentedCan someone confirm that it is still an issue on latest 2.0.x-dev branch and/or 3.x, please?
Problem might have been fixed with recent updates.
Comment #23
mably commentedUnless new, valuable information is provided, this issue will be closed in 3 months.
Comment #24
mably commentedThis could be definitely fixed by this issue's MR: #3547029: Initialize Domain before language negotiation
Comment #25
mably commentedComment #26
mably commentedThe original expected behavior is working perfectly fine when tested locally.
Closing for now.
Comment #28
mably commentedA new path prefix feature similar to what the country_path module is doing has been released in Domain 3.0.0-beta8.
Could solve the problem of those in need of mixing hostnames and path prefixes to handle multiple languages.