From 6ad625812a77dc1a63b3c88792b588de11ae8f3c Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Tue, 9 Sep 2025 16:01:04 -0400 Subject: Add a default language constant (#7933) This replace the use of `en` through out the code. --- lib/Minz/Request.php | 2 +- lib/Minz/Translate.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') 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[^;,]+)/', $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 @@ -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; } /** -- cgit v1.2.3