Skip to content

Commit b21c18a

Browse files
HarryThe3rdHarry Werkmeister
and
Harry Werkmeister
authored
fix: Issue #406 (#420)
This fix makes it possible that folder structures used in translation strings are used as group keys. Co-authored-by: Harry Werkmeister <h.werkmeister@careerpartner.eu>
1 parent 69eef1b commit b21c18a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/Manager.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,16 @@ public function findTranslations($path = null)
166166
$functions = $this->config['trans_functions'];
167167

168168
$groupPattern = // See https://regex101.com/r/WEJqdL/6
169-
"[^\w|>]". // Must not have an alphanum or _ or > before real method
170-
'('.implode('|', $functions).')'. // Must start with one of the functions
171-
"\(". // Match opening parenthesis
172-
"[\'\"]". // Match " or '
173-
'('. // Start a new group to match:
174-
'[a-zA-Z0-9_-]+'. // Must start with group
175-
"([.](?! )[^\1)]+)+". // Be followed by one or more items/keys
176-
')'. // Close group
177-
"[\'\"]". // Closing quote
178-
"[\),]"; // Close parentheses or new parameter
169+
"[^\w|>]" . // Must not have an alphanum or _ or > before real method
170+
'(' . implode('|', $functions) . ')' . // Must start with one of the functions
171+
"\(" . // Match opening parenthesis
172+
"[\'\"]" . // Match " or '
173+
'(' . // Start a new group to match:
174+
'[\/a-zA-Z0-9_-]+' . // Must start with group
175+
"([.](?! )[^\1)]+)+" . // Be followed by one or more items/keys
176+
')' . // Close group
177+
"[\'\"]" . // Closing quote
178+
"[\),]"; // Close parentheses or new parameter
179179

180180
$stringPattern =
181181
"[^\w]". // Must not have an alphanum before real method
@@ -202,7 +202,7 @@ public function findTranslations($path = null)
202202

203203
if (preg_match_all("/$stringPattern/siU", $file->getContents(), $matches)) {
204204
foreach ($matches['string'] as $key) {
205-
if (preg_match("/(^[a-zA-Z0-9_-]+([.][^\1)\ ]+)+$)/siU", $key, $groupMatches)) {
205+
if (preg_match("/(^[\/a-zA-Z0-9_-]+([.][^\1)\ ]+)+$)/siU", $key, $groupMatches)) {
206206
// group{.group}.key format, already in $groupKeys but also matched here
207207
// do nothing, it has to be treated as a group
208208
continue;

0 commit comments

Comments
 (0)