Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Issue barryvdh/laravel-translation-manager#406 #420

Merged
merged 1 commit into from
Mar 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,16 @@ public function findTranslations($path = null)
$functions = $this->config['trans_functions'];

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

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

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