mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-17573 added automatic downloading of parent languages
This commit is contained in:
parent
c33b83e77c
commit
07f6711889
@ -78,6 +78,12 @@
|
||||
|
||||
case COMPONENT_INSTALLED:
|
||||
$notice_ok[] = get_string('langpackinstalled','admin',$pack);
|
||||
if ($parentlang = get_parent_language($pack)) {
|
||||
// install also parent pack if specified
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'lang16', $parentlang.'.zip', 'languages.md5', 'lang')) {
|
||||
$cd->install();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case COMPONENT_UPTODATE:
|
||||
|
@ -5144,13 +5144,31 @@ function current_language() {
|
||||
|
||||
/**
|
||||
* Returns parent language of current active language if defined
|
||||
* @param string $lang null means current language
|
||||
* @return string
|
||||
*/
|
||||
function get_parent_language() {
|
||||
function get_parent_language($lang=null) {
|
||||
global $COURSE, $SESSION;
|
||||
|
||||
//let's hack around the current language
|
||||
if (!empty($lang)) {
|
||||
$old_course_lang = empty($COURSE->lang) ? '' : $COURSE->lang;
|
||||
$old_session_lang = empty($SESSION->lang) ? '' : $SESSION->lang;
|
||||
$COURSE->lang = '';
|
||||
$SESSION->lang = $lang;
|
||||
}
|
||||
|
||||
$parentlang = get_string('parentlanguage');
|
||||
if ($parentlang === '[[parentlanguage]]' or strpos($parentlang, '<') !== false) {
|
||||
return '';
|
||||
$parentlang = '';
|
||||
}
|
||||
|
||||
//let's hack around the current language
|
||||
if (!empty($lang)) {
|
||||
$COURSE->lang = $old_course_lang;
|
||||
$SESSION->lang = $old_session_lang;
|
||||
}
|
||||
|
||||
return $parentlang;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user