diff --git a/lang/bosniaAndHerzegovina/en/holidays.json b/lang/bosnia-and-herzegovina/en/holidays.json similarity index 100% rename from lang/bosniaAndHerzegovina/en/holidays.json rename to lang/bosnia-and-herzegovina/en/holidays.json diff --git a/src/Concerns/Translatable.php b/src/Concerns/Translatable.php index afd9f2084..3c13a6a1f 100644 --- a/src/Concerns/Translatable.php +++ b/src/Concerns/Translatable.php @@ -14,7 +14,8 @@ public function translate(string $country, string $name, ?string $locale = null) $locale = $locale ?? $this->defaultLocale(); - $countryName = strtolower($country); + $countryName = $this->toHyphenSeparated($country); + $filePath = __DIR__."/../../lang/{$countryName}/{$locale}/holidays.json"; if (file_exists($filePath)) { @@ -32,4 +33,11 @@ public function translate(string $country, string $name, ?string $locale = null) return $data[$name] ?? $name; } + + protected function toHyphenSeparated(string $text): string + { + return strtolower( + preg_replace('/(?<=\\w)(?=[A-Z])/', '-$1', $text) + ); + } }