diff --git a/admin/tool/langimport/index.php b/admin/tool/langimport/index.php
index 1180abc09a8..573a25e21f1 100644
--- a/admin/tool/langimport/index.php
+++ b/admin/tool/langimport/index.php
@@ -111,6 +111,20 @@ echo $OUTPUT->heading(get_string('langimport', 'tool_langimport'));
$installedlangs = get_string_manager()->get_list_of_translations(true);
$locale = new \tool_langimport\locale();
+
+if ($availablelangs = $controller->availablelangs) {
+ $remote = true;
+} else {
+ $remote = false;
+ $availablelangs = array();
+ $a = [
+ 'src' => $controller->lang_pack_url(),
+ 'dest' => $CFG->dataroot.'/lang/',
+ ];
+ $errormessage = get_string('downloadnotavailable', 'tool_langimport', $a);
+ \core\notification::error($errormessage);
+}
+
$missinglocales = '';
$missingparents = array();
foreach ($installedlangs as $installedlang => $langpackname) {
@@ -119,6 +133,16 @@ foreach ($installedlangs as $installedlang => $langpackname) {
$missinglocales .= '
'.$langpackname.'';
}
+ // This aligns the name of the language to match the available languages using
+ // both the name for the language and the localized name for the language.
+ $alang = array_filter($availablelangs, function($k) use ($installedlang) {
+ return $k[0] == $installedlang;
+ });
+ $alang = array_pop($alang);
+ if (!empty($alang[0]) and trim($alang[0]) !== 'en') {
+ $installedlangs[$installedlang] = $alang[2] . ' (' . $alang[0] . ')';
+ }
+
$parent = get_parent_language($installedlang);
if (empty($parent)) {
continue;
@@ -136,19 +160,6 @@ if (!empty($missinglocales)) {
$controller->errors[] = get_string('langunsupported', 'tool_langimport', $a);
}
-if ($availablelangs = $controller->availablelangs) {
- $remote = true;
-} else {
- $remote = false;
- $availablelangs = array();
- $a = [
- 'src' => $controller->lang_pack_url(),
- 'dest' => $CFG->dataroot.'/lang/',
- ];
- $errormessage = get_string('downloadnotavailable', 'tool_langimport', $a);
- \core\notification::error($errormessage);
-}
-
if ($controller->info) {
$info = implode('
', $controller->info);
\core\notification::success($info);