Problem/Motivation

In InstallerTestBase::setUpLanguage we must not translate the 'Save and continue' message, because in that state, the language is always english.

Proposed resolution

Remove the use of $this->translations on the 'Save and continue' button text.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chr.fritsch created an issue. See original summary.

chr.fritsch’s picture

Status: Active » Needs review
FileSize
539 bytes

Here is the patch

chr.fritsch’s picture

Version: 8.0.x-dev » 8.1.x-dev

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

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

Kristen Pol’s picture

Version: 8.9.x-dev » 9.1.x-dev
Component: simpletest.module » install system
Status: Needs review » Needs work
Issue tags: +Bug Smash Initiative, +Needs reroll

Needs a reroll. See core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php.

mrinalini9’s picture

Assigned: Unassigned » mrinalini9
mrinalini9’s picture

Assigned: mrinalini9 » Unassigned
Status: Needs work » Needs review
FileSize
604 bytes

Rerolled patch #2 for 9.1.x branch, please review.

Kristen Pol’s picture

Issue tags: -Needs reroll
Kristen Pol’s picture

Status: Needs review » Reviewed & tested by the community

I'm trying to understand if this change makes sense to me. Looking at the existing code in InstallerTestBase.php, I see 'Save and continue' used in:

  protected function setUpLanguage() {
    $edit = [
      'langcode' => $this->langcode,
    ];
    $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
  }
...
  protected function setUpProfile() {
    $edit = [
      'profile' => $this->profile,
    ];
    $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
  }
...
  protected function setUpSettings() {
    $edit = $this->translatePostValues($this->parameters['forms']['install_settings_form']);
    $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
  }
...
  protected function setUpSite() {
    $edit = $this->translatePostValues($this->parameters['forms']['install_configure_form']);
    $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
    // If we've got to this point the site is installed using the regular
    // installation workflow.
    $this->isInstalled = TRUE;
  }

Other than the above and other tests, I see 'Save and continue' in:

./core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php:      '#value' => $this->t('Save and continue'),
./core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php:      '#value' => 'Save and continue',
./core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php:      '#value' => $this->t('Save and continue'),
./core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php:      '#value' => $this->t('Save and continue'),
./core/modules/field_ui/src/Form/FieldStorageAddForm.php:      '#value' => $this->t('Save and continue'),

where SelectLanguageForm.phpis intentionally not using translation as noted in the comments:

 * Note that hardcoded text provided by this form is not translated. This is
 * because translations are downloaded as a result of submitting this form.

There are many classes that extend InstallerTestBase. For example, core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationMultipleLanguageTest.php where the parent method is called after adding the translation files:

  protected function setUpLanguage() {
    // Place custom local translations in the translations directory.
    mkdir(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
    file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this->getPo('de'));
    file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.es.po', $this->getPo('es'));

    parent::setUpLanguage();
  }

This looks like, while the translation files are written, they aren't yet loaded so the translations would not be available yet.

So, if I'm understanding correctly, the reason the code works before patching is because there is no translation yet available so English is just passed through as is. In that, the change makes sense to me. Given this and the following I'm marking RTBC:

1) Patch applies
2) Tests pass
3) Change is straightforward and addresses the problem noted in the issue summary
4) No manual testing should be need as it should be covered by automated testing

Though I'm wondering if it could use a comment so that it's clear why translation isn't used (similar to the comments for SelectLanguageForm.php).

Whether it's worth committing to core, that is update to the core maintainers. :)

Kristen Pol’s picture

Status: Reviewed & tested by the community » Needs work

Pulling this one back after thinking about it more. I think it needs a comment. I would suggest something like:

// Text is hardcoded since translations are not yet available.
ravi.shankar’s picture

Assigned: Unassigned » ravi.shankar
ravi.shankar’s picture

Assigned: ravi.shankar » Unassigned
Status: Needs work » Needs review
FileSize
672 bytes
582 bytes

Here I have addressed comment #16.

Kristen Pol’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the update.

1) Interdiff looks good.

2) Tests still pass.

3) Based on this and #15, marking RTBC.

jungle’s picture

Assigned: Unassigned » jungle
Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php
    @@ -219,7 +219,8 @@ protected function setUpLanguage() {
    -    $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
    

    The translations property should be removed. no usages in child classes., edited, I was wrong.

  2. +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php
    @@ -219,7 +219,8 @@ protected function setUpLanguage() {
    +    // Text is hardcoded since translations are not yet available.
    

    The comment is unnecessary to me, but happy to add it back.

jungle’s picture

Addressing #20. Not sure what I am doing is right, let's waiting for the testing run finishes.

Status: Needs review » Needs work

The last submitted patch, 21: 2691389-21.patch, failed testing. View results

Hardik_Patel_12’s picture

Status: Needs work » Needs review
FileSize
1.95 KB
629 bytes
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php
index 4268fbce6b..8f6e7c6a54 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php
@@ -54,17 +54,6 @@ abstract class InstallerTestBase extends BrowserTestBase {
    */
   protected $parameters = [];
 
-  /**
-   * A string translation map used for translated installer screens.
-   *
-   * Keys are English strings, values are translated strings.
-   *
-   * @var array
-   */
-  protected $translations = [
-    'Save and continue' => 'Save and continue',
-  ];
-

$translations is used by some child class like ConfigTranslationInstallTest who extending InstallerTestBase class so not removing this and just removing $this->translations from InstallerTestBase class. Kindly review a new patch

jungle’s picture

Thinking again, I would say that this is a won't fix. The original code is ok to me. It does not call t() nor new TranslatableMarkup(), Dont translate in the title does not make sense.

Status: Needs review » Needs work

The last submitted patch, 23: 2691389-23.patch, failed testing. View results

quietone’s picture

Issue summary: View changes
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php
@@ -229,7 +229,7 @@ protected function setUpProfile() {
-    $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
+    $this->drupalPostForm(NULL, $edit, 'Save and continue');

@@ -237,7 +237,7 @@ protected function setUpProfile() {
-    $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
+    $this->drupalPostForm(NULL, $edit, 'Save and continue');

@@ -257,7 +257,7 @@ protected function setUpRequirementsProblem() {
-    $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
+    $this->drupalPostForm(NULL, $edit, 'Save and continue');

These are all out of scope. The IS specifically says this is for \Drupal\FunctionalTests\Installer\InstallerTestBase::setUpLanguage() only.

Now the question is the 'select language' step of the install process only in English. I wasn't sure so I tested manually. Yes, it is always in English. The 'Save and continue' text is always English no matter what non-English language I selected for the installation. Based on that I would say the patch in #18 is on the right track. It just needs an improved comment.

+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php
@@ -219,7 +219,8 @@ protected function setUpLanguage() {
+    // Text is hardcoded since translations are not yet available.

This would be better if we included where this is hard coded (save the next dev some time). Something like this "The 'Select Language' step is always English.
@See \Drupal\Core\Installer\Form\SelectLanguageForm."

jungle’s picture

Status: Needs work » Needs review
FileSize
820 bytes
798 bytes

Thanks @quietone for the review.

Adjusted per @quietone's suggestion based on #18. But I still do not think the change/improvement here is necessary as I commented in #24.

Gábor Hojtsy’s picture

Priority: Normal » Minor
Status: Needs review » Reviewed & tested by the community

This makes sense. Its a minor fix at best though :) Thanks for looking at this.

  • catch committed 9b4c2f0 on 9.1.x
    Issue #2691389 by jungle, ravi.shankar, Hardik_Patel_12, mrinalini9:...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 9b4c2f0 and pushed to 9.1.x. Thanks!

Status: Fixed » Closed (fixed)

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