Problem/Motivation

If you are using an install profile to customize the installation experience, you'd better be using only strings that core itself uses, because your custom strings will never be translated.

This is because the early installer only ever downloads and reads translations for core. If there's a custom profile in play, its strings are completely ignored.

Drupal CMS runs into this because it uses a custom install profile, and it has to do some very dubious workarounds in order to get its translations loaded in the early installer. This is clearly a bug, because the installer supports custom profiles, and translation, but this scenario falls through the cracks.

Proposed resolution

install_download_translation() needs to download the profile's translations too! Additionally, \Drupal\Core\StringTranslation\Translator\FileTranslation needs to read translations not just for core, but also for the profile.

Release notes snippet

TBD

Issue fork drupal-3605554

Command icon 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

phenaproxima created an issue. See original summary.

phenaproxima’s picture

Issue summary: View changes
gábor hojtsy’s picture

I think this makes a ton of sense. Drupal CMS still still need to custom-download the .po file for the site template recipe chosen so its a shift in how the same code will be used in the CMS installer, but core could still do the profile already, it would make slightly less custom code in the CMS installer :)

phenaproxima’s picture

Issue summary: View changes
phenaproxima’s picture

Status: Active » Needs review

This was going to be way too hard to test functionally, so I did it as a reasonably high-level kernel test which confirms that translations are downloaded for custom profiles, but not core profiles.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.77 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

phenaproxima’s picture

Status: Needs work » Needs review

As far as I can tell (and I added more test coverage to confirm this), the version is passed through unaltered.

gábor hojtsy’s picture

Status: Needs review » Needs work

#3594389: Remove unecessary core dev version replacement in locale project info just landed. so much for dealing with the -dev suffix. Sorry, I was not aware that it works without that removed.

phenaproxima’s picture

Status: Needs work » Needs review

That simplifies things :) Removed the -dev special-casing.

gábor hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Yay, now this looks all good to me :)

quietone’s picture

Title: If using a custom profile, its translations are never loaded or downloaded » Translations are never loaded or downloaded for a custom profile
gábor hojtsy’s picture

BTW #3529211: The installer should download translations for the current install profile is a duplicate from a year ago that @phenaproxima also worked on. That was the first google result when I searched for this issue :D

alexpott’s picture

Version: main » 11.4.x-dev
Priority: Normal » Major
Status: Reviewed & tested by the community » Fixed

Committed and pushed e439b183f1d to main and de801c94f79 to 11.x and 1908b48df45 to 11.4.x. Thanks!

Great to see the kernel test for this. Nice one. Backported to 11.4.x and raising to major inline with the duplicate. As far as I can see the API tweaks here are all additions and will not cause breakages in the unlikely event that contrib or custom code is using these functions and classes.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

gábor hojtsy’s picture

Adding 11.5 highlights tag as we can group the profile related improvements compared to 11.4.0 nicely there I think, even if some are bugfixes.

  • alexpott committed 1908b48d on 11.4.x
    fix: #3605554 Translations are never loaded or downloaded for a custom...

  • alexpott committed de801c94 on 11.x
    fix: #3605554 Translations are never loaded or downloaded for a custom...

  • alexpott committed e439b183 on main
    fix: #3605554 Translations are never loaded or downloaded for a custom...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.