aboutsummaryrefslogtreecommitdiff
path: root/lib/Minz/Translate.php
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2025-09-09 16:01:04 -0400
committerGravatar GitHub <noreply@github.com> 2025-09-09 22:01:04 +0200
commit6ad625812a77dc1a63b3c88792b588de11ae8f3c (patch)
treef39a1d66f3e643193f9f1a9b343aca3a6b6525ee /lib/Minz/Translate.php
parentde624dc8ce63ec819c61216d9d44f828841c293e (diff)
Add a default language constant (#7933)
This replace the use of `en` through out the code.
Diffstat (limited to 'lib/Minz/Translate.php')
-rw-r--r--lib/Minz/Translate.php6
1 files changed, 4 insertions, 2 deletions
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;
}
/**