Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: i18n extensions: 'en' as fallback #5426

Merged
merged 2 commits into from May 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/Minz/Translate.php
Expand Up @@ -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();
Expand Down Expand Up @@ -125,9 +125,14 @@ public static function registerPath(string $path): void {
*/
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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug fixed in #5752

$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(
Expand Down