Skip to content

Commit

Permalink
fix: prevent type error when translation key is null (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
slepic authored Nov 10, 2023
1 parent 2738298 commit 51d2183
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Localization/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function translate($key, ...$parameters): string
{
if (isset($this->dictionary[$key])) {
$message = $this->dictionary[$key];
} elseif (preg_match('/^([A-Za-z]\w+\.)+\w+$/', $key)) {
} elseif ($key && preg_match('/^([A-Za-z]\w+\.)+\w+$/', $key)) {
$message = '|' . $key . '|';
} else {
$message = $key;
Expand Down

0 comments on commit 51d2183

Please sign in to comment.