language_negotiation_matrix
This module enhances Drupal Language Negotiation URLs. By providing a way to map languages to paths or domains in a way that does not confuse the User when using the Language Switcher.
Take for example a site with a domain called this.example.domain and it has two languages, french and english. Now this site exists on a path, let's say /lives/here for english and /habit/la for french. Now, let's assume the client also wishes prefixes to exist. Such that /lives/here/en is the final path for the english site and /habit/la/fr for the french. I know, sounds crazy, but it happens. The problem with this is that your combination of language paths now look like this:
this.example.domain/lives/here/enthis.example.domain/lives/here/frthis.example.domain/habit/la/frthis.example.domain/habit/la/en
As you can see, this is not ideal. We really need these to be the following:
this.example.domain/lives/here/enthis.example.domain/habit/la/fr
This module helps to map the languages to their path prefixes and domains. Ensuring a simple matrix of languages to paths.
In the event you have a site with multiple languages which exists in sub-folders and / or with sub-domains, in one combination or several. These can complicate matters for language switching. Especially since flipping between languages can impact legal or political matters.
This module attempts to provide a simple solution for getting around these problems.
Configuration
Please take a moment to review the documentation and make sure you've properly configured your server for use with this module. The module alone is not enough to make the paths and domains work as desired.
N.B.: There is some server level pathing required in some circumstances.
When using paths and domains which force the Drupal installation cookies to work with complex pathing, you will have to modify the parameters in the *.services.yml file:
parameters:
session.storage.options:
cookie_domain: '.localhost'
cookie_samesite: 'Lax'
Note: If using a wildcard . to denote "anything before the domain", if you are using "domain matrix" the cookie may not work as intended. Either explicitly mark the domain or subdomain component which the cookie will adhere to otherwise user sessions won't work from one language to another.
Optional Modules
If you wish to take advantage of the Keys module to include and work with environment variables, this module makes use of the plugins it provides to create its own group of keys.