10.April 2026
This commit is contained in:
parent
a00c42e770
commit
f58c709945
208 changed files with 19280 additions and 2914 deletions
30
app/Services/LocaleGuard.php
Normal file
30
app/Services/LocaleGuard.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
class LocaleGuard
|
||||
{
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function supportedLocaleCodes(): array
|
||||
{
|
||||
return array_keys(config('localization.supportedLocales'));
|
||||
}
|
||||
|
||||
public static function isSupported(string $locale): bool
|
||||
{
|
||||
return in_array(strtolower($locale), self::supportedLocaleCodes(), true);
|
||||
}
|
||||
|
||||
public static function normalize(?string $locale): ?string
|
||||
{
|
||||
if ($locale === null || $locale === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$lower = strtolower($locale);
|
||||
|
||||
return self::isSupported($lower) ? $lower : null;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue