Skip to content

Commit

Permalink
MDL-70768 tool_langimport: Make installed admin UI more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanheywood committed Feb 10, 2021
1 parent 4e398ff commit 17e465c
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions admin/tool/langimport/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@
$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) {
Expand All @@ -119,6 +133,16 @@
$missinglocales .= '<li>'.$langpackname.'</li>';
}

// 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] . ' &lrm;(' . $alang[0] . ')&lrm;';
}

$parent = get_parent_language($installedlang);
if (empty($parent)) {
continue;
Expand All @@ -136,19 +160,6 @@
$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('<br />', $controller->info);
\core\notification::success($info);
Expand Down

0 comments on commit 17e465c

Please sign in to comment.