Problem/Motivation
Core installer calls locale module functions without checking the module enabled
Steps to reproduce
1) create install profile with custom languages and make it dependent on language module only (locale module should not be listed in profile)
2) try to install site from that profile
Error: Call to undefined function locale_translation_use_remote_source() in /srv/core/includes/install.core.inc on line 1632
Error: Call to undefined function locale_translation_use_remote_source() in install_import_translations() (line 1632 of /srv/core/includes/install.core.inc).
The problem in install_import_translations() that trying to use locale module functions without checking it enabled
Some notes about it in first code coment install_tasks()
Proposed resolution
Do not try import translations when no locale module enabled
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
andypostThe main reason to skip translation import is API first site
Comment #3
andypostproper title
Comment #4
andypostInitial stub
Comment #5
andypostAnother errors to fix
Comment #6
andypostFixed patch
Comment #8
gábor hojtsyErm, what happens is the installer forces locale module to be enabled when installing in a foreign language. Otherwise import translations and finish translations would not even be added as batch items, no?
Comment #9
andypostYep, by default installer ui enables locale and language modules when other then English selected but when install happens with CLI we need full control of what modules to install.
So we provide languages and settings in default config and point all dependent modules in profile.info.yml
When locale is not listed here it will not enabled automatically (that causes install to fail now) but ui installer works as before.
I don't think we need to change ui of install and auto enabling locale, but we need to allow CLI install without locale
Comment #10
gábor hojtsySo why does the UI install work then and should we just not add these batch steps for the CLI install either if we are to exit from them immediately?
Comment #11
andypostGood point, looks better to skip them then hacking inside!
Also maybe it makes sense to add a checkbox "Skip translation import" on install screens?
Comment #12
gábor hojtsyWhy would you expose that to users? Does not sound like something a person who is exposed to Drupal the first time would be able to decide?
Comment #13
andypostNice question, I think having enabled this checkbox on language selection page could confuse newcomers
And developers using to install sites with drush mostly so yep it useless in 80% cases
Then patch needs to move this conditions to prevent this batches to run
Comment #14
andypostProbably sort of that should work
Comment #15
hog commentedComment #16
andypost@HOG no, only prevent translations download/import
Better skip both
Comment #18
hog commentedPatch #16 work. Tested on custom profile with custom language.
Comment #19
xjmComment #20
xjmThis is a bugfix and should be safe to commit during beta, at least, but is not eligible for commit during RC, so tagging with that deadline.
Comment #21
gábor hojtsyThis totally breaks the default installation flow with language selection, given that of course when the task list is generated, the locale module is not (dynamically) added yet to the list of modules on the profile. So picking a foreign language in the installer does not do anything with this patch. That is a pretty serious side effect :)
Comment #22
gábor hojtsyWhat happens with this patch is there is no language download/translation happening after you pick the language in the installer. Then you need to go through the installer in English and it will only get translated once locale is in fact installed (because the additional steps are added then), so your site configuration screen in the installer is then translated but not the prior ones.
Comment #23
andypostIt does, installer UI enables locale module so only when you by-pass installer UI you can set modules that you need (drush)
That means that only console installers allows you to pass locale module
Comment #24
andypostI mean that custom profile/module could change default language in container
if they need single language API-site with other then English by default
Comment #25
gábor hojtsy@andypost:
1. Go to this link: http://simplytest.me/project/drupal/8.2.x?patch[]=https://www.drupal.org...
2. Install Drupal in a language other than English
3. Observe that the installer is English throughout the installer up until the Configure screen
4. This is not good.
Comment #27
antonnaviHi all!
This is a good idea have ability disable translations adding for speedup Drupal installation in specific cases.
Reviewed patch from #16 comment and checked how installer translation works:
install_select_languageuser select not default language, for example Frenchinstall_download_translationif selected not default language - Drupal download "po" file for selected language: /sites/default/files/translations/drupal-8.2.0-dev.fr.po$_GET['langcode']if it not "en" - translate strings usingDrupal\Core\StringTranslation\Translator\FileTranslation(it works with "po" file directly and get translations from it)Means: We can't overwrite
$needs_downloadvariable because we lost installer translation. But we can play with$needs_translationsand speedup installation with disabling translations import.Usage "locale" module state (installed/no) for definition should be translation imported or no is not so good: because in some cases "locale" module can be needed (enabled) and translations import can be be not needed (for more fast installation). We can use additional param like translations_import: no in profile
.info.ymlfile instead.@all what do you think about additional param in profile
.info.ymlfile usage ?Comment #28
tkoleary commentedComment #30
xjmComment #32
wim leersI don't think this is per-se API-First related. Many/most API-First sites still use Drupal's UI for managing content.
Comment #35
bpizzillo commentedThis issue seems to be more "lively" than #2413191, but the approach in #2413191 seems to be less intrusive than patches in this thread.
I am currently experiencing an issue (with 8.7-dev) in a profile where English is the default language, Spanish is being added, I don't have locale enabled, I have even downloaded the Spanish translation and it still breaks. It seems like the
$needs_translationscheck should not just check\Drupal::languageManager()->isMultilingual(), but it should also check if locale is installed.For those concerned with cases where English is not the selected language, then it probably should be an error if locale has not been enabled at that point.
What exactly are peoples' blockers to having a check for locale to be enabled before trying to enable a translation?
Also is 2413191 a duplicate of this issue, or is this a duplicate of it?
Comment #46
smustgrave commentedSo this came up as daily BSI target
Looking at the code I see
Which was added in #2413191: Shipping a profile with multiple languages without locale module not possible.
So is this one outdated? Credit could be moved over.