Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
How do i set up the language default in each domain
3 languages installed and 3 domains
English
Russian
Spanish
en.mysite.com = english
ru.mysite.com = russian
es.mysite.com = spanish
Comment | File | Size | Author |
---|---|---|---|
#24 | interdiff.txt | 12.33 KB | Sebastien M. |
#24 | domain-language_default-2775809-D8-24.patch | 19.65 KB | Sebastien M. |
#21 | domain-language_default-2775809-D8-21.patch | 20.25 KB | Sebastien M. |
Comments
Comment #2
agentrickardYou should be able to do this with Domain Config.
You'll want to clone the "system.site" configuration and set the proper values.
So in this case, you would create the following file:
domain.config.ru_mysite_com.system.site.yml
Which contains:
Note that all the items in that new YML file are optional. See the documentation in domain_config/README.md.
Then load that into your configuration as a "Simple Configuration file."
Comment #3
RobertoGuzman CreditAttribution: RobertoGuzman commentedquestion ?
in this case i have 4 domains and i would like only enable x languages in x domains
mysite.com = english
= spanish
= russian
en.mysite.com = english
= spanish
es.mysite.com = spanish
= english
ru.mysite.com = russian
Comment #4
RobertoGuzman CreditAttribution: RobertoGuzman commentedthere is an error importing this configuration, but here is a patch to fix this error
https://www.drupal.org/node/2740983
Comment #5
RobertoGuzman CreditAttribution: RobertoGuzman commentedthe front page with translaticios does not work
node/1 = translated to 3 languages, english | russian | spanish
en.mysite.com = node/1 = english
ru.mysite.com = node/1 = russian
es.mysite.com = node/1 = spanish
the 3 domains comes with
en.mysite.com = node/1 = english
ru.mysite.com = node/1 = english
es.mysite.com = node/1 = english
Comment #6
agentrickardThat's a render cache issue. See the instructions in the Domain Config README concerning required_cache_contexts in services.yml.
We've never seen that import error. What did you name the file? How did you try to import it?
Comment #7
agentrickardComment #8
joebest CreditAttribution: joebest commentedIMPORTANT: What would be the answer for question #3
Comment #9
agentrickardIt looks like (though I have not tested), you may need to create a domain-specific language.negotiation.yml file for each domain. And then a domain-specific language.entity.LANGCODE.yml file as well.
Take the following generic case, where I enabled English and Afrikaans on a normal Drupal site.
In the sample below, we disable Afrikaans on one domain. I would expect that you need a domain file for the negotiation:
And one for the language, where status is set to false:
These files are in addition to the domain-sensitive default language override.
Comment #10
RobertoGuzman CreditAttribution: RobertoGuzman commentedHow do i add multilingual variables ?
MySite.com
EN = My Site
ES = Mi Sitio
RU = Мой сайт
Comment #11
agentrickardThat last question does not have enough context to be answerable.
Comment #12
garnett2125 CreditAttribution: garnett2125 commentedHi agentrickard,
So if I understand correctly, domain doesnt work as it used to, where you could manage available languages per domain directly from the backoffice.
Now we have to use language negotiation files ?
Thanks
Comment #13
agentrickardThat is correct.
Comment #14
RobertoGuzman CreditAttribution: RobertoGuzman commentedfollowing your comment # 2
domain.config.ru_mysite_com.system.site.yml
Which contains:
name: 'Russian site name'
langcode: ru
default_langcode: ru
i created my own configuration like this
domain.config.es_misitio_com.system.site
name: 'mi sitio'
langcode: es
default_langcode: es
this configuration made the changes in the name of the site, but it does not make any change in the language default
the main site has 2 languages, English (en) and Spanish (es)
I'm using Drupal core 8.2.1 and Domain Access 8.x-1.0-alpha5+1-dev (2016-Oct-26)
Comment #15
garnett2125 CreditAttribution: garnett2125 commentedIt looks like it is not possible to disable a language on a specific domain because this feature has been drope, see:
https://www.drupal.org/node/1539072
Comment #16
RobertoGuzman CreditAttribution: RobertoGuzman commentedgarnett2125, your comment is regarding to set a default language or disabling a language in a domain ?
Comment #17
garnett2125 CreditAttribution: garnett2125 commentedRegarding to disable a language, we can not use the property status set to false to do it.
But the default language doesn't work either.
Comment #18
RobertoGuzman CreditAttribution: RobertoGuzman commentedgarnett2125, is there any work around how to make the default language in another domain, different from the defaut in the main site ?
Comment #19
Sebastien M. CreditAttribution: Sebastien M. commentedHi all,
This weekend I worked on this issue. I found an interesting solution and I'm currently working on a patch which could end by a "domain_language" submodule.
This goal is to set the default language and limit suggested languages by domain.
My current work is about generating config UI to simplify administration.
I hope to able to provide a patch by the end of this week.
See you
Comment #20
RobertoGuzman CreditAttribution: RobertoGuzman commentedgreat, thanks
Comment #21
Sebastien M. CreditAttribution: Sebastien M. as a volunteer commentedHere is a first draft of a new submodule dedicated to handle language restrictions: "Domain Language".
I need to review the code and comment it, but globally it is currently fully efficient.
A new entry is now available in the domain admin listing, to handle "Language" settings.
I've been obliged to alter a few the DomainConfigOverride class to be able to access to the Domain object instance before settings default language.
Is this situation, there is one or two calls to this override while "domain language overrides" are not called because default language is not known.
Let me know if you think it's acceptable or not.
Feel free to test it and report any issue (entity error, route error, needs cache reset ...).
Comment #22
RobertoGuzman CreditAttribution: RobertoGuzman commentedSebastien @Actualys, works perfectly, thank you
Comment #23
RobertoGuzman CreditAttribution: RobertoGuzman commenteddoes this patch will be included in the next release ?
Comment #24
Sebastien M. CreditAttribution: Sebastien M. as a volunteer commentedA new release of my patch after a code review/clean.
Comment #25
RobertoGuzman CreditAttribution: RobertoGuzman commentedi have an issue, i'm using Drupal core 8.2.3 and Domain Access 8.x-1.0-alpha6 and i used the patch domain-language_default-2775809-D8-24.patch.
domains
main site 2 languages = English and Spanish => default language English
sub domain 1 has the same language configuration as the main site
when i run the database update with drush = drush updatedb i get this error
nexpectedValueException: External URLs do not have an internal route name. in Drupal\Core\Url->getRouteName() (line 554 of /home/public_html_8/core/lib/Drupal/Core/Url.php).
I fixed the error clearing the cache thru the main site admin
Comment #26
Sebastien M. CreditAttribution: Sebastien M. as a volunteer commentedHi Roberto,
My patch has been made on top of the DEV branch.
Did you encountered any notice while applying the patch ?
Did you see this issue on a fresh and "standard" install ?
BR
---------------
in addition, can you indicate me which "domain" modules has been activated and any other modules than drupal core's ?
Comment #27
RobertoGuzman CreditAttribution: RobertoGuzman commentedi found what was creating the error, the Superfish module, I have created 2 menus, 1 for english, 1 for spanish, both menu block was activated, and each one visible for their own language.
The error disappear as soon i deactivate the 2 superfish blocks
Comment #28
Sebastien M. CreditAttribution: Sebastien M. as a volunteer commentedNice news.
Thanks for your feedback.
So, currently, no drawback related to the last patch ?
Comment #29
RobertoGuzman CreditAttribution: RobertoGuzman commentedhi Sebastien @Actualys, no, it is working fine, no errors at all by the moment
Comment #30
garnett2125 CreditAttribution: garnett2125 commentedWorks perfectly for me too =)
Thanks for the patch
Comment #31
mike.vindicate CreditAttribution: mike.vindicate commentedI can confirm this patch works with Domain: 8.x-1.0-alpha6.
No clean installation needed, works with existing domain access configuration.
Thanks for the patch.
Comment #32
RobertoGuzman CreditAttribution: RobertoGuzman commenteddoes the latest patch is include in the Domain Access 8.x-1.0-alpha7 or the latest Domain Access 8.x-1.x-dev (2016-Dec-13) ?
Comment #33
Sebastien M. CreditAttribution: Sebastien M. as a volunteer commentedThe latest patch is not included in the last release and no more in the dev branch.
@RobertoGuzman I think you could send a private post to the project owner to ask him to review this patch.
Comment #34
RobertoGuzman CreditAttribution: RobertoGuzman commentedquestion, what is the issue do not include your patch in the new release when your patch enhance or add a feature to the module ?
This is a community, which anyone can improve and make the system better
just a personal comment
Comment #35
Sebastien M. CreditAttribution: Sebastien M. as a volunteer commentedCurrently, this issue is only flagged as "Reviewed & tested by the community". The project owner needs to review this patch, merge the patch to the DEV branch and flag this issue "Fixed".
However, if he estimate that the patch is not done correctly, not in the right way ... he has the power to reject it and ask for more work.
That's too the power of community ;-)
Comment #36
agentrickard@RobertoGuzman That's really a complex question. Here's the state of things.
* I work in this module in my spare time
* Multilanguage suppoprt is not a core feature.
* I do my primary work in GitHub -- as noted on the project page -- largely because the Drupal issue queue is too noisy to be efficient.
This patch introduces:
* Complex behavior changes
* A new module that I am being asked to maintain.
* New hooks.
* A change (?) to how configuration is stored -- I really don't understand why that is there. Domain Config needs to handle that use case.
And it includes no tests.
I'm not going to commit any code that doesn't have tests, and it would take me several hours to write tests for this patch.
This patch also may collide with existing work going on in https://github.com/agentrickard/domain/pull/294.
@Sebastien @Actualys -
This is really cool stuff, but I really can't support it in the main module. I simply don't have the time and the use-case for it.
Clearly, just overriding language configuration is not sufficient. What we need is for someone to maintain a Domain Language module release, separate from the main module suite.
I'm more than happy to support API changes or patches that you need to make that work, but I also need to understand that changes that are being made here:
* Why the changes to DomainConfigOverrider?
* Why do we need DomainLanguageOverrider? -- Can't those changes be put into DomainConfigOverrider?
* What is DomainLanguageServiceProvider actually changing? (I think I get it, but naming the class LangugeDefault is very confusing. I would make it DomainLanguageDefault for clarity.
The rest seems to be form handling, which makes sense, but potentially interferes with what's going on in Domain Config (as noted above).
Comment #37
Sebastien M. CreditAttribution: Sebastien M. as a volunteer commented@agentrickard during the domain negotiation, the "DomainConfigOverrider" use the language manager to detect the current language.
I agree this is necessary to correctly use override mecanism of "domain config", but this force to detect the language, even if we want to restrict available languages against a domain.
In fact, language detection should be done after the domain negotiation, so the domain negatiation should be done very very early.
By switching those lines it fixes the situation, but the overriding mecanism won't be able to correctly load "domain + language" overrides.
That's why I've done the other updates on this class.
If you agree for these updates on "DomainConfigOverrider", I'll be able to create a new module to support "Domain Language" restrictions.
Unless you want to integrate this fix in the core "Domain" module.
I hope I was enough clear. If not, don't hesitate.
Thanks
Comment #38
agentrickardYes, let's make DomainConfigOverrider work properly to support both domain + language. Figuring out the order in which those variables are available has been difficult.
Can you spin that up as a separate patch (or pull request)?
Comment #39
agentrickardReviewing some old issues, I ran into this module -- https://www.drupal.org/project/domain_lang -- so there may be some coordination to do?
Comment #40
Sebastien M. CreditAttribution: Sebastien M. as a volunteer commentedHi all,
The patch has been migrated into this module:
https://www.drupal.org/project/domain_language
Comment #41
andypostBasically this can be achieved with domain_config module default language lives in
system.site
so easy to overrideComment #42
Sebastien M. CreditAttribution: Sebastien M. as a volunteer commented`domain_config` allows such overrides. If it was so easy, this issue should be closed a long time ago.
Indeed language negotiation uses it own mechanism to load configs thanks to dependency injection, unless it has been updated (in Drupal Core or in Domain module).
This is mainly due to the fact that domain uses the current language to load the overridden file (name base on both domain id and language), so the language is negotiated before that domain itself can detect on which domain we are ...
Comment #43
AntonnaviHere is our implementation of restriction languages list per domain:
https://github.com/skilld-labs/domain_language/tree/8.x-1.x
Currently it's a test version.
Comment #44
Sebastien M. CreditAttribution: Sebastien M. as a volunteer commentedSeems to be part of my patch, done 3 months ago, integrated as a standalone module hosted on github.
I don't understand the situation.
@agentrickard This issue seems to turn around
Comment #45
andypostThis is a totally different approach, that focused on different language negotiation settings and ability to define language subsets inside domain entity
Comment #46
agentrickardHandling multi-language options isn't something I've had time to dig into.
The problem of default language per domain, as I recall, was simple. Restricting languages per domain was hard.
I am interested in the problem of loading domain-specific language overrides when, as Sebastien @Actualys notes, we're using language prefixing to load domain overrides.
Do we need to be loading domain overrides first and then domain-and-language overrides? That might be the correct answer. The current code in the main Domain modules just says "load language-and-domain if it exists else load domain."
That's what the code in http://cgit.drupalcode.org/domain_language/tree/src/DomainLanguageOverri... seems to be doing. If that's the case, we can change the loading behavior in Domain Config to make that domain_language module obsolete, I think.
But both modules introduce a UI as well, which I haven't had time to write.
Am I correct that the GitHub version swaps out the core LanguageManager for a domain-specific one? That's something I was hoping to avoid having to do.
Comment #47
andypostI think there's other way to solve it.
domain_config module should add to container parameter (not config setting to be not affected by config overrides) that will enable language-aware domain overrides
Implementation in domain_config module will provide alter of domain settings form to enable that, the additional submit handler will check for change of the property (checkbox) and will rebuild container with proper parameter if changed.
That may require to store this property in config somehow, but this is how core's language manager rebuilds container on default language change
Comment #48
andeersg CreditAttribution: andeersg at Bouvet commentedI've been reading through this thread and I'm wondering what the best solution to override language config right now is? Is it the domain_language module for now?
Comment #49
rcodina CreditAttribution: rcodina commentedDomain language module works fine!
Comment #50
agentrickardClosing.
These types of issues where extra logic is needed to handle non-standard core configurations are out of scope and should be handled in separate modules.
https://www.drupal.org/project/domain_language
Comment #51
rcodina CreditAttribution: rcodina commentedMaybe this Domain language module could be linked in the main Domain Access project page along with other D8 related projects like Domain Country Path.
Comment #52
andypostAlso there's https://www.drupal.org/project/domain_lang which we actively used a year ago
PS: There's Ecosystem reference in every project, so maintainers need to point this field to domain access
See example at https://www.drupal.org/project/domain_entity
It builds the list https://www.drupal.org/project/domain/ecosystem