Skip to content

Commit

Permalink
Merge pull request #73 from Laravel-Lang/2.x
Browse files Browse the repository at this point in the history
Fixed string search error
  • Loading branch information
andrey-helldar authored Mar 22, 2024
2 parents 3716bc0 + 7649c04 commit 58738a4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Services/Packages/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Finder
protected array $contains = [
'__(',
'$t(',
'$fail(',
'fail(',
'lang(',
'Lang::choice(',
'Lang::get(',
Expand Down
19 changes: 16 additions & 3 deletions src/Services/Packages/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function parse(string $content): void
continue;
}

if ($this->isKeyName((string) $value)) {
if ($this->isNotTranslatable((string) $value)) {
continue;
}

Expand Down Expand Up @@ -148,10 +148,23 @@ protected function subMethods(): array
->toArray();
}

protected function isKeyName(string $value): bool
protected function isNotTranslatable(string $value): bool
{
return Str::contains($value, '.')
return $this->isKey($value)
|| $this->isHeader($value);
}

protected function isKey(string $value): bool
{
return Str::contains($value, ['.', '-', '_', ':'])
&& ! Str::contains($value, ' ')
&& $value === Str::lower($value);
}

protected function isHeader(string $value): bool
{
return Str::contains($value, '-')
&& ! Str::contains($value, ' ')
&& ($value === Str::lower($value) || $value === Str::title($value));
}
}

0 comments on commit 58738a4

Please sign in to comment.