mirror of
https://github.com/moodle/moodle.git
synced 2025-06-01 13:46:35 +02:00
MDL-69788 lang: fallback to all translations if misconfigured.
If given translation list contains only invalid entries, fallback to returning the complete list of available language translations.
This commit is contained in:
parent
149fdcf075
commit
59ec5b1851
@ -533,7 +533,13 @@ class core_string_manager_standard implements core_string_manager {
|
||||
$languages[$langcode] = !empty($this->transaliases[$langcode]) ? $this->transaliases[$langcode] : $langname;
|
||||
}
|
||||
}
|
||||
return $languages;
|
||||
|
||||
// If there are no valid enabled translations, then return all languages.
|
||||
if (!empty($languages)) {
|
||||
return $languages;
|
||||
} else {
|
||||
return $cachedlist;
|
||||
}
|
||||
}
|
||||
|
||||
// Get all languages available in system.
|
||||
@ -584,7 +590,12 @@ class core_string_manager_standard implements core_string_manager {
|
||||
}
|
||||
}
|
||||
|
||||
return $languages;
|
||||
// If there are no valid enabled translations, then return all languages.
|
||||
if (!empty($languages)) {
|
||||
return $languages;
|
||||
} else {
|
||||
return $cachedlist;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,6 +140,13 @@ class core_string_manager_standard_testcase extends advanced_testcase {
|
||||
|
||||
$this->assertEquals(['en' => 'En'], $stringman->get_list_of_translations());
|
||||
|
||||
// Set invalid config, ensure original list is returned.
|
||||
set_config('langlist', 'xx');
|
||||
$this->assertEquals(['en' => 'English (en)'], get_string_manager(true)->get_list_of_translations());
|
||||
|
||||
set_config('langlist', 'xx,en|En');
|
||||
$this->assertEquals(['en' => 'En'], get_string_manager(true)->get_list_of_translations());
|
||||
|
||||
set_config('langlist', '');
|
||||
get_string_manager(true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user