From 05a319bd350d03e286c507790b7b207de9760212 Mon Sep 17 00:00:00 2001 From: Merel Jossart Date: Wed, 24 Jan 2024 10:44:57 +0100 Subject: [PATCH] Fix: regex for twig translate did not properly account for possible spaces in twig syntax --- src/services/Translate.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/Translate.php b/src/services/Translate.php index 26be351..3d87d82 100644 --- a/src/services/Translate.php +++ b/src/services/Translate.php @@ -39,9 +39,9 @@ class Translate extends Component // Regex for |t('category') 'twig' => array( // Single quotes - "/'([^']+)'\|(t|translate)/mu", + "/'([^']+)'\ *\|\ *(t|translate)/mu", // Double quotes - '/"([^"]+)"\|(t|translate)/mu', + '/"([^"]+)"\ *\|\ *(t|translate)/mu', ), // Regex for Craft.t('category', '..') @@ -255,7 +255,7 @@ private function _processFile(string $path, string $file, ElementQueryInterface public function parseString($expression, $string) { - $string = preg_replace("/\r?\n|\r|\n/", " ",$string); + $string = preg_replace("/\r?\n|\r|\n/", " ", $string); $string = preg_replace('!\s+!', ' ', $string); preg_match_all($expression, $string, $matches); return $matches;