Problem/Motivation

Spaces before or after a string that you search to translate returns nothing.

Steps to reproduce

1. Install the "Interface Translation" (locale) module.
2. Go to /admin/config/regional/translate
3. Search for "More " with two spaces before or after.

Proposed resolution

Use php trim function to remove space from search string value.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

julien created an issue. See original summary.

julien’s picture

paulocs’s picture

Assigned: julien » paulocs
Status: Active » Needs work

We should add test for it.
I'll do it.

paulocs’s picture

Version: 8.9.x-dev » 9.2.x-dev
Assigned: paulocs » Unassigned
Status: Needs work » Needs review
Issue tags: +Bug Smash Initiative
FileSize
694 bytes
1.41 KB

Tagging the Bug smash initiative and adding test case.

Status: Needs review » Needs work

The last submitted patch, 4: 3179258-4.patch, failed testing. View results

julien’s picture

Updated the test to use a variable name_ws with whitespace, which would be trimed, and assert that name is in the results.

julien’s picture

Status: Needs work » Needs review
paulocs’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Novice

This change is suitable for a novice.

+++ b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php
@@ -81,10 +81,13 @@ public function testStringTranslation() {
+    // Add a whitespace at the end of string to ensure that it's finded.

s/to ensure that it's finded./to ensure it is found./
The past tense of find is found.

julien’s picture

Status: Needs work » Needs review
FileSize
1.54 KB
paulocs’s picture

Status: Needs review » Reviewed & tested by the community

Moving to RTBC as patch #10 fixes what @quietone pointed on comment #9.

  • larowlan committed d598f54 on 9.2.x
    Issue #3179258 by julien, paulocs: Spaces before or after a string...
larowlan’s picture

Title: Spaces before or after a string searched to be translated returns nothing. » [backport] Spaces before or after a string searched to be translated returns nothing.
Version: 9.2.x-dev » 9.1.x-dev

Committed d598f54 and pushed to 9.2.x. Thanks

Leaving as RTBC and moving to 9.1.x for possible backport after the code-freeze is finished.

alexpott’s picture

Title: [backport] Spaces before or after a string searched to be translated returns nothing. » Spaces before or after a string searched to be translated returns nothing.
Status: Reviewed & tested by the community » Fixed

Sure let's backport this. Makes the search a bit more lenient which is a nicer UX.

  • alexpott committed 9719c35 on 9.1.x authored by larowlan
    Issue #3179258 by julien, paulocs: Spaces before or after a string...

Status: Fixed » Closed (fixed)

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