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

andypost created an issue. See original summary.

andypost’s picture

The main reason to skip translation import is API first site

andypost’s picture

Title: Core fails to install when no locale module enabled but there's other languages » Allow to skip trnslation import for API first sites
Issue tags: -language-content +API-First Initiative, +language-interface

proper title

andypost’s picture

Status: Active » Needs review
StatusFileSize
new986 bytes

Initial stub

andypost’s picture

Title: Allow to skip trnslation import for API first sites » Allow to skip translations import for API first sites

Another errors to fix

Error: Call to undefined function locale_translation_build_projects() in /srv/core/includes/install.core.inc on line 1720
Error: Call to undefined function locale_translation_build_projects() in install_finish_translations() (line 1720 of /srv/core/includes/install.core.inc).
andypost’s picture

StatusFileSize
new1.3 KB
new1.86 KB

Fixed patch

The last submitted patch, 4: 2770113-4.patch, failed testing.

gábor hojtsy’s picture

Status: Needs review » Needs work
Issue tags: +sprint

Erm, 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?

andypost’s picture

Yep, 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

gábor hojtsy’s picture

So 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?

andypost’s picture

Good point, looks better to skip them then hacking inside!

Also maybe it makes sense to add a checkbox "Skip translation import" on install screens?

gábor hojtsy’s picture

Why 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?

andypost’s picture

Issue tags: +Usability

Nice 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

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new844 bytes

Probably sort of that should work

hog’s picture

andypost’s picture

StatusFileSize
new933 bytes

@HOG no, only prevent translations download/import

Better skip both

The last submitted patch, 15: allow_to_skip_translations-2770113-15.patch, failed testing.

hog’s picture

Status: Needs review » Reviewed & tested by the community

Patch #16 work. Tested on custom profile with custom language.

xjm’s picture

Title: Allow to skip translations import for API first sites » Allow to skip translations import for API-first sites
xjm’s picture

Issue tags: +rc deadline

This 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.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

This 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 :)

gábor hojtsy’s picture

What 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.

andypost’s picture

So picking a foreign language in the installer does not do anything

It 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

andypost’s picture

Status: Needs work » Needs review

I mean that custom profile/module could change default language in container
if they need single language API-site with other then English by default

gábor hojtsy’s picture

Status: Needs review » Needs work

@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.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

antonnavi’s picture

Hi 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:

  1. During first step install_select_language user select not default language, for example French
  2. Next step install_download_translation if selected not default language - Drupal download "po" file for selected language: /sites/default/files/translations/drupal-8.2.0-dev.fr.po
  3. Next steps check $_GET['langcode'] if it not "en" - translate strings using Drupal\Core\StringTranslation\Translator\FileTranslation (it works with "po" file directly and get translations from it)

Means: We can't overwrite $needs_download variable because we lost installer translation. But we can play with $needs_translations and 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.yml file instead.

@all what do you think about additional param in profile .info.yml file usage ?

tkoleary’s picture

Issue tags: -Usability

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

xjm’s picture

Issue tags: -rc deadline

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

wim leers’s picture

Title: Allow to skip translations import for API-first sites » Allow to skip translations import
Issue tags: -API-First Initiative

I don't think this is per-se API-First related. Many/most API-First sites still use Drupal's UI for managing content.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

bpizzillo’s picture

This 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_translations check 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?

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Bug Smash Initiative

So this came up as daily BSI target

Looking at the code I see

$locale_module_installed = \Drupal::moduleHandler()->moduleExists('locale');
  $needs_translations = $locale_module_installed && ((count($install_state['translations']) > 1 && !empty($install_state['parameters']['langcode']) && $install_state['parameters']['langcode'] != 'en') || \Drupal::languageManager()->isMultilingual());
  

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.