diff --git a/src/Concerns/Translatable.php b/src/Concerns/Translatable.php index 3c13a6a1..8599863e 100644 --- a/src/Concerns/Translatable.php +++ b/src/Concerns/Translatable.php @@ -36,8 +36,12 @@ public function translate(string $country, string $name, ?string $locale = null) protected function toHyphenSeparated(string $text): string { - return strtolower( - preg_replace('/(?<=\\w)(?=[A-Z])/', '-$1', $text) - ); + $toHyphens = preg_replace('/(?<=\\w)(?=[A-Z])/', '-$1', $text); + + if ($toHyphens === null) { + return strtolower($text); + } + + return strtolower($toHyphens); } }