diff options
Diffstat (limited to 'lib')
| -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; } /** |
