mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
Merge branch 'MDL-70768-langpack-admin' of https://github.com/brendanheywood/moodle
This commit is contained in:
commit
e85b1f9c0f
@ -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 .= '<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] . ' ‎(' . $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('<br />', $controller->info);
|
||||
\core\notification::success($info);
|
||||
|
Loading…
x
Reference in New Issue
Block a user