Problem/Motivation
Recently, on a new site, I've switched the default language from English to a different language. I've exported the config and reinstalled the site. I've discovered that English language has vanished. Lately I've discovered that I need to add keep_english: true in my custom profile. Took me 1 hour to find this.
We need somehow to inform the site builder about this before they lose their mind.
Steps to reproduce
See above.
Proposed resolution
If the profile doesn't have keep_english on, show a warning after the default language is switched from English that instructs the site builder what they need to do.
Nice to have: An intermediary screen/form where the user is presented with the warning and is able to cancel until the issue is fixed.
Further reflection: Maybe keep_english is not a profile thing but a site config?
Remaining tasks
Clarify the warning message.
User interface changes
To be clarified.
API changes
None.
Data model changes
None.
Release notes snippet
To be clarified.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3545306-3.png | 63.16 KB | rob c |
| #4 | admin-config-regional-language-nl-confirm-default.png | 51.52 KB | rob c |
Issue fork drupal-3545306
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 #3
rob c commentedSomething like this?
I got the form working, but could use some guidance on additional text we need to display. (this will set your site language to x, update your config language when you install a module, etc)
Creating a UpdateLanguageSubscriber now, so you can't access the form if (for example) 'en' already is the default language or if you only have one language. And this needs tests (+ still need to update existing test). Then i'll attempt my first merge request / contribution in a decade or something, so gonna be fun.
And after all this we can update #3337864: Introduce a dedicated "Configuration default language" different from "Site default language" and add some bits in this new form (or something else).
Comment #4
rob c commentedApologies, the correct screenshot:
Comment #5
ressaThanks for working on this @rob c, perhaps we could also consider linking to the documentation page https://www.drupal.org/docs/administering-a-drupal-site/multilingual-gui... which itself links to relevant issues? (under "4. Set a default language.")
Comment #6
rob c commentedHey your all welcome. This one was (after reviewing a ton of issues) really bugging me, so i figured let's have a go at it. ( #3150540: Configuration langcode is forced to site default language etc. a long long list ).
I've added the link like you suggested and i have pushed the current code. Still needs more text i think (describing the impact of this change if 'keep_english' is not set). Out of time this week, but this needs more work before a full review, and still needs additional tests (a test profile with keep_english: true, test for the EventSubscriber - or go another route, etc) / need to rework the EventSubscriber, but at least we have something to look at now. Back at it next monday (maybe this weekend).
Comment #7
ressaThank you so much for a fast answer, and already adding the link, I think that looks great.
Multilingual support in Drupal works really well overall, but there are still edge cases and things that can be improved -- like weird things happening (as in this issue), or cumbersome processes like translating config, which I ran into myself last year (see #3549927: Streamline translation of Views block titles, custom menu titles, etc.: Allow Interface Translation). So all improvements are very welcome :)
Comment #8
gábor hojtsyI don!t understand this issue. I don't think keep_english in the profile has any consequence to default language change on the site later on. If you have keep_english then the INSTALLER will keep English on the site despite installing in a foreign language. If you install in a non-English language, English will not be present so you don't get confusing language selectors for example on monolingual foreign language sites :) You should perfectly be able to remove English on such sites. But if you install in English, then add a foreign language, then switch the site default to that foreign language on the UI, nothing will remove English? I don't think anything will.
Comment #9
berdir> the INSTALLER
from issue summary:
> I've exported the config and *reinstalled* the site
This is a install-from-config edge case I assume, so that installer cleanup logic apparently runs then as well.
Comment #10
gábor hojtsyRight, that is why I don't understand how the default language switch form should / would help to warn about this or what has that have to do about it. So if I understand this right then the right title would be Installation from config removes English if the installed profile does not have keep_english which sounds like is by design? Or I don't understand this properly.
Comment #11
gábor hojtsyI asked my GPT codex LLM to analyze the problem:
Questions as a human for this issue: Are there other parts of a profile that should be used in the config install? What does specifying the profile mean in a config based install? Should we expect part of the profile info not apply in config based install?
Comment #12
gábor hojtsyThere is also special consideration in the install_finish_translations() step to protect config translation overrides when installing from config, so that kind of logic could apply to where the profile removes English.
Comment #13
gábor hojtsyThere is actually already
install_config_revert_install_changes(), which is added ininstall_tasks()for the config install use case. This attempts to protect the English language with this:So we do have an attempt to avoid this issue. Why does this not work? Is
ConfigurableLanguage()cached and should be loaded fresh?