Problem/Motivation
A multilingual (English and Spanish) website should be installed as part of the Umami OOTB experience.
Having that in core would also allow the ability to submit patches that will fix various Umami's multilingual issues (ie. View that displays only recipes in the current language, etc.)
Having that in core would also allow the ability to submit patches to fix Umami's multilingual issues (ie. View that displays only content in current language, etc.)
Proposed resolution
Enable the 4 language related core modules -
- language
- config_translation
- content_translation
- locale
Add config files to the demo_umami install profile that would enable English and Spanish.
If a user chooses to install Umami any other language, English and Spanish should still be enabled in addition to the language the user chose.
Remaining tasks
Create and update the config files for demo_umami install profile.
Comment | File | Size | Author |
---|---|---|---|
#57 | interdiff-54-57.txt | 257 bytes | smaz |
#57 | ootb-multilingual-spanish-3029839-57.patch | 26.33 KB | smaz |
#54 | ootb-multilingual-spanish-3029839-54.patch | 26.34 KB | smaz |
#52 | ootb-multilingual-spanish-3029839-52.patch | 26.31 KB | smaz |
#47 | ootb-multilingual-spanish-3029839-45-47-interdiff.txt | 2 KB | smaz |
Comments
Comment #2
shaalI created an initial patch that enables the 4 language core modules, and add configuration for demo_umami to enable Spanish as a second language.
What works so far
When Installing Umami in English or any other language - Spanish will be added as a second language.
What still needs fixing
* (see screenshot) Even that Spanish is installed and works out of the box with this patch, the website displays a warning message that only one language was installed (which is false)
* How to enable English when a user doesn't install Umami in English
Comment #3
mcannon CreditAttribution: mcannon at FFW commented@shaal,
I tested this patch and can confirm it works. I also started looking into the other issue about the warning message. This happens because of when the "content_translation" module is installed, there is only one language setup from step 1 of the install process. So when the module's "hook_install()" is triggered, it checks for more then one language and sets this warning if not. All warnings triggered stay on the screen of the profile page.
I dug around and found a ticket about this issue Create multilingual install profile which makes it sound like a lot needs to change to make this correctly possible. Starting with making a site multilingual during step 1 down to the more complex making all entities, fields, etc... translatable. There's a lot of talk in the ticket about this being an improvement for Drupal 9.
It looks like before this task can be accomplished, the install process needs to be changed along with a long list of other things.
Comment #4
Gábor HojtsyTo fix the issue you see in the installer, just swap the order of language to be first and then the others. Best in this order:
- language
- locale
- config_translation
- content_translation
In this case, when content translation gets enabled, the languages will already be there, so it will not display that warning.
Comment #5
Gábor HojtsyEven then, the config translations (config/install/languages/*/*) will not get automatically imported. That just does not work in core. See https://cgit.drupalcode.org/multilingual_demo/tree/multilingual_demo.pro... which is almost entirely needed to have the config translations imported. Except the first function.
Comment #6
Gábor Hojtsy@mcannon I would not wait for the installer to be all rosy and great, that should not block demonstrating what Drupal can do. Just lift the code needed and run with it IMHO :)
Comment #7
shaalI updated the patch -
keep_english: true
After the installation process finishes, I'm still getting what seems to be a false warning message (see screenshot below).
When I manually checked - all translations and languages installed.
I tested installation in various options in the first installation screen - English, Spanish, and Hebrew.
Comment #9
shaalPatch with codesniffer fixes.
Comment #11
Gábor HojtsyLooks like some layout builder changes crept in. Also:
This will only be needed once you start shipping with field config files that specify the fields as translatable, eg. https://cgit.drupalcode.org/multilingual_demo/tree/config/install/field.... and I am not sure it is still needed anyway then.
Comment #12
shaaloops. no idea how this layout builder code sneaked into the patch.
Removed layout builder, and removed creation of translation fields as part of Umami installation.
Comment #13
shaalComment #15
Eli-TNote as discussed following the initiative call, it wasn't the original intention to translate the Drupal user interface to Spanish in this initial scope of work - it was merely about demonstrating Drupal's content translation. That may not have been apparent.
We need to work out whether it is now more or less work to proceed with the UI also translated and if the apparent additional install time is acceptable.
Comment #16
shaalTesting Drupal 8 locally, installation timings:
At the time of installation, maybe we can present a choice - Regular Umami vs Full multilingual Umami?
Comment #17
Gábor HojtsyI think its a good idea to make multilingual optional. There are two options:
1. Make two install profiles. Umami $language_user_selected and Umami Multilingual.
2. Umami injects a config screen right after the profile selection screen to pick which option to go with and then does dynamic stuff based on that.
I am not 100% sure it is possible to inject a config screen (AKA installer task) right after profile selection, but it may very well be possible.
Comment #18
Gábor HojtsyDiscussed with @shaal. Making two profiles would require #1356276: Allow profiles to define a base/parent profile unfortunately if you don't duplicate the code (which we don't want), so that is indeed, out of the way.
However option 2 can be done with https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension... theoretically. That can inject a config form right after the profile step to ask about multilingual (and any other demo related setup config that should happen before modules get installed). I personally never had a form added this early in the installer, but since the profile selection and the language selection before it are forms, this should work.
Comment #19
Gábor HojtsyIf that does not work, the demo installation can be reworked to happen after the existing built-in site config form and then
hook_form_install_configure_form_alter()
can be used to alter the config form to ask for additional details on that config form.Comment #20
Gábor Hojtsy@shaal: I was reviewing this for differences with the multilingual_demo profile, and while I could not pinpoint the issue that causes content translation to be enabled before the config is imported, I found another issue. The install/languages/* files should be entirely removed from the patch, there is no reason to ship those with the profile, they will get created as translations from localize.drupal.org once the default config is included with Umami. Consequently I realized you don't need the config translation import code in the profile at all either, because once the config is part of Umami's default config, it will be translatable on localize.drupal.org and get translated as long as locale module is enabled, no need to duplicate that heavy lifting.
These will probably not solve the issues experienced but make the patch significantly simpler.
Comment #21
shaalGoing back to patch #2.
I removed
install/languages/*
filesIn
core/profiles/demo_umami/demo_umami.info.yml
:I added
keep_english: true
per @Gábor Hojtsy, I updated the order of modules -
During installation, the following warnings (that we should fix) appear:
Comment #22
Gábor HojtsyComment #24
shaal@Gábor Hojtsy I tested multilingual_demo on Drupal 8.7.x, 8.6.x, 8.5.10
I am getting the same warnings (only a single language enabled, enable translations...) during installation.
The only difference is when the installation completes, I see the homepage without the warning.
Comment #25
shaalAdded related issue During installation some links get wrong prefix of /code/install.php
Comment #26
Gábor HojtsyOk it is true that config import is after modules being installed (see
install_tasks()
) so whatever order we do that is not going to help. We should fix the content translation module to not inform people about problems when installed as part of installing Drupal, when actual config is not there. If somebody installs the module as part of Drupal's installation, they should know what they are doing.I think this proof of concept is probably the ugliest variant of the fix, but it should work :D We may be able to get the config storage from the container and see if its an InstallStorage instance or some more elegant looking fix. I looked if there was something in the special installer container that we can just directly query to know if we are in the installer or not, but did not find anything. If there would be an actual API that would be the best.
This will only make the first two warnings go away. The import problem would be fixed by fixing the translations themselves. We can also try to make sure that is not output but that is on locale module then. The import summary is probably also not useful to display as part of the installation I guess, it certainly distracts here.
Anyway, let's see first how/if this fixes content_translation.
Comment #27
Gábor HojtsyShould skip both messages, not just the one that had the condition.
Comment #28
Gábor HojtsyThe locale messages actually have an API to not be printed, that is finish_callback => FALSE can be passed into the batch builder and then the finish callback is not added to the import batch (which is otherwise only about printing the messages). This can be used in the "additional translations" process in the installer which is about downloading and importing translations that are for projects enabled in the install process that were not part of core.
The fetch batch process that is used to import the initial translation does have a finish callback that couples printing the messages and updating the fetch timestamp which is unfortunate. We can add our own finish callback to only update the timestamp.
I think these should stop the messages from being shown for all locale import in the installer for all profiles. I *think* this is more in line with what people expect, after all we don't report on the imported config either even though when you explicitly import config then you get to see that reported. The installation is such a complex operation that it is hard to assume that you would be interested specifically about the translation string imports as a big box on the page :) It is a lot of technical detail anyway. I don't know why we made it appear in the installer in the first place.
Comment #32
andypostComment #33
Gábor HojtsyOk only the settings.php message remains. I think rather than not calling locale_translate_batch_finished() at all, we should figure out a way for that to be able to log messages but not be noisy about them and make finish_feedback respond to that. Ie. pass into the batch results somehow.
Also @alexpott points out in chat that
Which is definitely a nicer way of depending on the global install state :) https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/functi...
Solve this later one, the former one needs fixing still.
Comment #34
Gábor HojtsySo this is how the result looks now:
I don't think the settings.php message is new to this patch?
Comment #35
Gábor HojtsyProof of concept for a better batch silencing solution where logs are saved but user feedback is not output. That was/is the documented meaning of the finish_feedback option btw, so that it does not work that way is a bug.
Comment #38
Gábor HojtsyHm, this fails with
and
I don't have time today anymore to track that down, theoretically the results so passing on to @shaal hopefully :)
The test fails are within Umami's own tests, those need resolved as well.
Comment #39
Gábor HojtsySo the problem is we are adding the store_finish_feedback in one of the locale include files and then run this batch from another one :/ Locale import is such a mess. We can add an independent callback there, but it should ideally be actually used in the built-in batch creation in locale as well.
This should work better but is not really done for that reason.
Comment #41
shaalI fixed the warning messages in #39 by changing it to
isset
check.There's now a new message to the user, before the Congratulations message:
No configuration objects have been updated.
Here's how the page look when the installation process is finished:
Comment #42
Gábor HojtsyChanging to isset() is not a good idea, that just masks the problem. The problem is that the option does not get stored on the batch so if somebody wanted to display feedback that would not work anymore. So let's not do that!
I opened #3034784: Displaying translation string counts and string errors is too much detail in the installer to break that issue out, since it happens with standard profile and is pre-existing. Let's only deal with the content translation module here which is a problem this issue exposes first in core.
Patch is same as #39 except all locale and install.core.inc changes are removed. (Those are now in #3034784: Displaying translation string counts and string errors is too much detail in the installer).
Comment #45
smazTrying to fix the config issue but having trouble running tests locally so not 100% sure this will work first time!
Comment #46
smazNew patch coming in a mo - there are a couple of config files that have been added that aren't needed.
Comment #47
smazI have removed:
These were not needed as part of the proffile, not needed for the installation to work & are added by the language/locale modules when they are enabled.
Comment #48
Gábor HojtsyThese are also included as default, why are you including them then if zxx was removable as it was added? That should be true for the others (with keep_english for the English as well).
Comment #49
smazlanguage.negotiation.yml is required as we have configured that for Spanish so differs from the defaults provided by the module.
I think the other two can be removed - will give it a test!
Cheers!
Comment #50
Gábor HojtsyComment #51
smazComment #52
smazI was able to remove language.entity.en.yml & language.types.yml.
I think there's a few things that need changing from the default install / this patch (e.g. English not using /en prefix) - but I think they're covered by other issues / we can work on this afterwards. This patch is holding up a lot of other multilingual work, so we might as well get this added & then fine tune if needed.
Comment #54
smazFixed merge conflicts + setting to needs review.
Comment #55
shaalI tested Umami installation using patch #54 in various languages:
Installation went smooth with no errors.
I was able switch between
/
,/en
,/es
and get the expected results:Pages that were tested:
Comment #56
Gábor HojtsyLooks good to me other than:
This empty line should be removed.
Comment #57
smazFixing the whitespace issue - as that's all, setting back to RTBC.
Comment #59
smazTriggering testbot again as it looks like it was having a rough time earlier...
Comment #60
smazComment #62
MixologicIndeed. Very rough time.
dispatcher/testbot issue. back to rtbc.
Comment #63
alexpottThis looks like a good approach to not showing the messages during an install. Which would be the wrong time - because they'll show on the site configure form at the end of installing the modules +1.
Comment #64
Gábor HojtsySuperb, thanks for confirming @alexpott. Since that was the only thing I contributed to in this patch, I put this in! Let's continue with making the blocks csv and importing the multilingual content.
Comment #65
Gábor HojtsyFor some reason commits did not show up here, it is in git though: https://cgit.drupalcode.org/drupal/commit/?h=8.8.x&id=afbdd37f72f480d477...