Skip to content

Commit

Permalink
Fix: regex for twig translate did not properly account for possible s…
Browse files Browse the repository at this point in the history
…paces in twig syntax
  • Loading branch information
Numkil committed Jan 24, 2024
1 parent 5d08f31 commit 05a319b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/services/Translate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '..')
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 05a319b

Please sign in to comment.