diff options
| author | 2025-09-09 16:01:04 -0400 | |
|---|---|---|
| committer | 2025-09-09 22:01:04 +0200 | |
| commit | 6ad625812a77dc1a63b3c88792b588de11ae8f3c (patch) | |
| tree | f39a1d66f3e643193f9f1a9b343aca3a6b6525ee /lib/Minz | |
| parent | de624dc8ce63ec819c61216d9d44f828841c293e (diff) | |
Add a default language constant (#7933)
This replace the use of `en` through out the code.
Diffstat (limited to 'lib/Minz')
| -rw-r--r-- | lib/Minz/Request.php | 2 | ||||
| -rw-r--r-- | lib/Minz/Translate.php | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index 2f76b9aa8..a41ddb0a6 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -515,6 +515,6 @@ class Minz_Request { if (preg_match_all('/(^|,)\s*(?P<lang>[^;,]+)/', $acceptLanguage, $matches) > 0) { return $matches['lang']; } - return ['en']; + return [Minz_Translate::DEFAULT_LANGUAGE]; } } diff --git a/lib/Minz/Translate.php b/lib/Minz/Translate.php index 17290574c..c824186fa 100644 --- a/lib/Minz/Translate.php +++ b/lib/Minz/Translate.php @@ -11,6 +11,8 @@ declare(strict_types=1); * It uses files in `./app/i18n/` */ class Minz_Translate { + public const DEFAULT_LANGUAGE = 'en'; + /** * $path_list is the list of registered base path to search translations. * @var array<string> @@ -99,7 +101,7 @@ class Minz_Translate { */ public static function getLanguage(?string $user, array $preferred, ?string $default): string { if (null !== $user) { - if (!self::exists($user)) return 'en'; + if (!self::exists($user)) return self::DEFAULT_LANGUAGE; return $user; } @@ -111,7 +113,7 @@ class Minz_Translate { } } - return $default == null ? 'en' : $default; + return $default ?: self::DEFAULT_LANGUAGE; } /** |
