Problem/Motivation
There is sometimes a need to override a configuration based on interface language. Good examples are homepage, 403, 404 pages. Even though pages typically should use entity translation, some limitations like Paragraphs not being translatable force alternative node pages per language.
There is an issue for core (#2275865: Per language settings (vs translated settings) are not directly supported) but discussions mention this could be solved in contrib, even if it probably should go in core at some point, there is some need to have it in contrib as there is some demand.
Proposed resolution
I propose to implement language overrides using Config Override module, essentially we can mimic the structure of config_translation in core but no UI.
Example of usage:
Include language_override config key in settings.php
$config_directories['language_override'] = '../config_override/language';
Place an override file in 'language_override' folder following core's config_translation structure:
[language_override]/en/system.site.yml
page:
front: /node/123
Remaining tasks
Add tests
User interface changes
None
API changes
New way to override configs, no changes to exiting APIs
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 2914987-3.patch | 4.35 KB | asgorobets |
Issue fork config_override-2914987
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
asgorobets commentedComment #3
asgorobets commentedProviding an initial patch and added example of usage.
Comment #4
dawehnerNice feature! It would be indeed really cool to have some test coverage for it as well.
Comment #5
marjina-constantin commentedUsed "Config overrride" module and patch from #3 on a production site to override some configs based on language + based on environment. Saved me a lot of time. Great work, thanks @asgorobets!
Comment #6
dawehner@asgorobets Is there any way I can help you with adding a test coverage?
Comment #7
asgorobets commentedThanks @dawehner, I will work on tests for it, will let you know if I need any help
Comment #8
sic commentedi have trouble getting this to work. i want to define another front node id for a specific language so in /sites i added the "config_override" folder, in it the "language" folder, and in it the language-code named folder ("de") for instance. and in it is the yml file from your example.
in /sites/default/settings.php i added the path from your example as well, no luck. any tipps?
Comment #9
lamp5I have got similar problem. When use this module with site prefix. All works properly! But now i using domains and for example if i override lang "de" to node/654 and in the rest of sites I using node/123 like a front page, override only works when i go to node/654 "de" and change language. Now i am on node/123 "en", but when i now change language to "de", a am on node/123 "de" instead node/654. I had a problem with domains and use this patch https://www.drupal.org/project/drupal/issues/2643466
Comment #10
jas1988 commentedIs this patch still valid ie: allow language overrides, With Drupal 8.9.1 it gives below error :
But editing config file directly is working fine : https://www.drupal.org/project/drupal/issues/3097497
Comment #11
tetem commentedHello,
I had some issue when I try to override config usig "Config Override Module"
The reason why is not working for me because I set my class AdamConfigOverrides outside the "src" folder
before : to /modules/custom/my_module/AdamConfigOverrides.php=> KO
error:
after /modules/custom/my_module/src/AdamConfigOverrides.php => OK
It worked for me
Comment #14
markie commentedStarted this MR because #5 uses deprecated code which was removed in D9.
Comment #15
jascote commentedA couple notes that may be helpful for others...
The most recent PR in #14 alters the location of the language override directories from what is stated in the issue description. Instead of placing your files in
[language_override]/en/system.site.ymlyou need to place them inside the config directory you have set in$settings['config_sync_directory']This seems to be a result of https://www.drupal.org/node/3018145 and is related to this issue https://www.drupal.org/project/config_override/issues/3243107
Despite making these changes this patch doesn't seem to work. Running
drush cimappears to create the new configs but the changes are not reflected on the site.In my case my config directory is this:
$settings['config_sync_directory'] = '../config/sync';My translation override files are here:
config/sync/en-ca/system.site.ymlWith the file contents of
Yet after running config import the global homepage node is still used.
Comment #16
dpagini commentedGiven the above comments, I think the "Needs work" tag is most appropriate here. I also don't have a lot of multi-lingual experience in Drupal, so tests would really be helpful to see this issue get more traction.