diff options
| author | 2023-05-28 18:02:04 +0200 | |
|---|---|---|
| committer | 2023-05-28 18:02:04 +0200 | |
| commit | eeefbdf9c720790b83cc82fd981929bf4d699120 (patch) | |
| tree | fdcc417fc33b6dbc2850c3bc4aa15265db9249df /lib/Minz/Translate.php | |
| parent | df80913747795e330af5c90e6d1b782b3d6d8f07 (diff) | |
Fixed: i18n extensions: 'en' as fallback (#5426)
* Update Translate.php
* Small improvements
---------
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'lib/Minz/Translate.php')
| -rw-r--r-- | lib/Minz/Translate.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Minz/Translate.php b/lib/Minz/Translate.php index 87ae4a9ff..0c8810377 100644 --- a/lib/Minz/Translate.php +++ b/lib/Minz/Translate.php @@ -37,7 +37,7 @@ class Minz_Translate { * Init the translation object. * @param string $lang_name the lang to show. */ - public static function init(?string $lang_name = null): void { + public static function init(string $lang_name = ''): void { self::$lang_name = $lang_name; self::$lang_files = array(); self::$translates = array(); @@ -125,9 +125,14 @@ class Minz_Translate { */ private static function loadLang(string $path): void { $lang_path = $path . '/' . self::$lang_name; - if (!file_exists($lang_path) || self::$lang_name == '') { - // The lang path does not exist, nothing more to do. - return; + if (self::$lang_name === '' || !is_dir($lang_path)) { + // The lang path does not exist, fallback to English ('en') + self::$lang_name = 'en'; + $lang_path = $path . '/' . self::$lang_name; + if (!is_dir($lang_path)) { + // English ('en') i18n files not provided. Stop here. The keys will be shown. + return; + } } $list_i18n_files = array_values(array_diff( |
