From d598f54100dac5096d052dbbec12adbe6ed8f403 Mon Sep 17 00:00:00 2001 From: Lee Rowlands <lee.rowlands@previousnext.com.au> Date: Wed, 4 Nov 2020 13:50:28 +1000 Subject: [PATCH] Issue #3179258 by julien, paulocs: Spaces before or after a string searched to be translated returns nothing --- core/modules/locale/src/Form/TranslateFilterForm.php | 2 +- .../locale/tests/src/Functional/LocaleTranslationUiTest.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/modules/locale/src/Form/TranslateFilterForm.php b/core/modules/locale/src/Form/TranslateFilterForm.php index cfa3b696e8e7..f7a3d20ec113 100644 --- a/core/modules/locale/src/Form/TranslateFilterForm.php +++ b/core/modules/locale/src/Form/TranslateFilterForm.php @@ -85,7 +85,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $filters = $this->translateFilters(); foreach ($filters as $name => $filter) { if ($form_state->hasValue($name)) { - $_SESSION['locale_translate_filter'][$name] = $form_state->getValue($name); + $_SESSION['locale_translate_filter'][$name] = trim($form_state->getValue($name)); } } $form_state->setRedirect('locale.translate_page'); diff --git a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php index c0c0654c5d4b..dee8d835164c 100644 --- a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php @@ -81,10 +81,13 @@ public function testStringTranslation() { $this->assertText(t($name), 'Test language added.'); $this->drupalLogout(); + // Add a whitespace at the end of string to ensure it is found. + $name_ws = $name . " "; + // Search for the name and translate it. $this->drupalLogin($translate_user); $search = [ - 'string' => $name, + 'string' => $name_ws, 'langcode' => $langcode, 'translation' => 'untranslated', ]; -- GitLab