diff --git a/src/Services/Packages/Finder.php b/src/Services/Packages/Finder.php index 69b8ebb..73d9438 100644 --- a/src/Services/Packages/Finder.php +++ b/src/Services/Packages/Finder.php @@ -14,7 +14,7 @@ class Finder protected array $contains = [ '__(', '$t(', - 'fail', + '$fail(', 'lang(', 'Lang::choice(', 'Lang::get(', @@ -23,6 +23,8 @@ class Finder 'trans_choice(', 'wTrans(', 'wTransChoice(', + 'getTranslator()->get(', + 'getTranslator()->choice(', ]; protected array $files = []; diff --git a/src/Services/Packages/Parser.php b/src/Services/Packages/Parser.php index bab54db..1b463fc 100644 --- a/src/Services/Packages/Parser.php +++ b/src/Services/Packages/Parser.php @@ -24,6 +24,8 @@ class Parser 'trans_choice', 'wTrans', 'wTransChoice', + 'get', + 'choice', ]; protected string $trim_chars = "\t\n\r\0\x0B'\""; @@ -72,6 +74,14 @@ protected function parse(string $content): void foreach ($this->match($content) as $match) { $value = $match; + if (Str::contains((string) $value, '$')) { + continue; + } + + if ($this->isKeyName((string) $value)) { + continue; + } + if (Str::contains((string) $value, $this->subMethods())) { $sub_key = $this->subkey($value); @@ -123,8 +133,10 @@ protected function trim($value): mixed protected function regex(): string { - $methods - = Arr::of($this->trans_methods)->implode('|')->replace(['$', '(', ')'], ['\$', '\(', '\)'])->toString(); + $methods = Arr::of($this->trans_methods) + ->implode('|') + ->replace(['$', '(', ')'], ['\$', '\(', '\)']) + ->toString(); return sprintf($this->regex, $methods); } @@ -135,4 +147,11 @@ protected function subMethods(): array ->map(fn (string $method) => Str::finish($method, '(')) ->toArray(); } + + protected function isKeyName(string $value): bool + { + return Str::contains($value, '.') + && ! Str::contains($value, ' ') + && $value === Str::lower($value); + } }