Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
phpunit
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
28 Jul 2026 at 13:41 UTC
Updated:
15 Sep 2026 at 17:40 UTC
Jump to comment: Most recent
In order to install Drupal in a test system in a different language you need to do:
/**
* {@inheritdoc}
*/
protected function installParameters(): array {
$parameters = parent::installParameters();
$parameters['parameters']['langcode'] = 'de';
// Create a po file so we don't attempt to download one from
// localize.drupal.org and to have a test translation that will not change.
\Drupal::service('file_system')->mkdir($this->publicFilesDirectory . '/translations', NULL, TRUE);
$contents = <<<PO
msgid ""
msgstr ""
PO;
file_put_contents($this->publicFilesDirectory . '/translations/drupal-' . \Drupal::VERSION . '.de.po', $contents);
return $parameters;
}
Let's make this simple by introducing a trait that tests can use to install Drupal in different language and it should also make it easy to add translations.
None
N/a
New test trait
None
N/a
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
alexpottComment #4
kentr commentedCan you do some of this in a way that's usable outside of automated tests, to help with manual testing / review of issues related to translation? For example, with a recipe?
Comment #5
alexpott@kentr is the first thing you answer in the interactive installer and is an option on both
dr installanddrush site-install... not sure there's much more we could do for that. Changing the default language of a site is currently fraught so install and then changing that is not going to be solved in a single issue.Comment #6
kentr commented@alexpott
I just meant installing from scratch with translation fully set up and a different language loaded, not changing the default language of an existing site.
For me, the interactive installer on
12.x-dev(i.e., when working on core issues) doesn't work because the translation files don't exist:I've had to manually download and import
11.xversions of translation files.drush site-install --locale=esalso doesn't install a translation file:Translation file not found: https://ftp.drupal.org/files/translations/all/drupal/drupal-12.0-dev.es.podr installwon't overwrite an existing site, AFAICT. So reinstalling with a different branch on a dev environment is tedious.Can something like a recipe can overcome this?
It would be more helpful if it just adds a language anyway, so that one can toggle. That would probably also help with automated testing of issues like #2921627: Do not use a CSS-only required marker in forms per WCAG 2.0.
Comment #7
alexpott@kentr - that will be fixed by #3605895: Drupal core main branch does not have corresponding .po files on localize.drupal.org until first alpha is tagged, fall back one major version
Comment #8
gábor hojtsyI really like this simplification. The fail seems to be entirely unrelated though. I sent that bit for a retest.
Comment #10
amateescu commentedCommitted f2d2322 and pushed to main. Thanks!
Needs a rebase on 11.x.
Comment #12
amateescu commentedI backported it myself. The only difference is that the changes to
LocaleNonInteractiveInstallTestwere dropped, because that test was changed in #3359322: Fix various tests that fail every time we open a new major branch in main and not backported to 11.x.Committed ca32739 and pushed to 11.x. Thanks!