From: skodak Date: Sat, 7 Feb 2009 18:55:21 +0000 (+0000) Subject: MDL-17565 automatic download of parent lang + parent lang cleanup X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=cc8727451fb72d8d9c088d044bf60987f2d5e045;p=moodle.git MDL-17565 automatic download of parent lang + parent lang cleanup --- diff --git a/install.php b/install.php index f39e91bb1f..00e7c7979e 100644 --- a/install.php +++ b/install.php @@ -381,6 +381,13 @@ if ($config->stage == INSTALL_DOWNLOADLANG) { } else { $downloaderror = get_string($cd->get_error(), 'error'); } + } else { + // install parent lang if defined + if ($parentlang = get_parent_language()) { + if ($cd = new component_installer('http://download.moodle.org', 'lang16', $parentlang.'.zip', 'languages.md5', 'lang')) { + $cd->install(); + } + } } } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index a45b7f8a22..fd64f76e5a 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -5142,6 +5142,18 @@ function current_language() { return $return; } +/** + * Returns parent language of current active language if defined + * @return string + */ +function get_parent_language() { + $parentlang = get_string('parentlanguage'); + if ($parentlang === '[[parentlanguage]]' or strpos($parentlang, '<') !== false) { + return ''; + } + return $parentlang; +} + /** * Prints out a translated string. * @@ -5441,7 +5453,7 @@ function get_string($identifier, $module='', $a=NULL, $extralocations=NULL) { if (eval($result) === FALSE) { trigger_error('Lang error: '.$identifier.':'.$langfile, E_USER_NOTICE); } - if (!empty($parentlang)) { // found it! + if (!empty($parentlang) and strpos($parentlang, '<') === false) { // found it! //first, see if there's a local file for parent $locallangfile = $location.$parentlang.'_local'.'/'.$module.'.php'; @@ -5726,7 +5738,7 @@ function get_list_of_countries() { if (!file_exists($CFG->dirroot .'/lang/'. $lang .'/countries.php') && !file_exists($CFG->dataroot.'/lang/'. $lang .'/countries.php')) { - if ($parentlang = get_string('parentlanguage')) { + if ($parentlang = get_parent_language()) { if (file_exists($CFG->dirroot .'/lang/'. $parentlang .'/countries.php') || file_exists($CFG->dataroot.'/lang/'. $parentlang .'/countries.php')) { $lang = $parentlang; @@ -5813,7 +5825,7 @@ function get_list_of_pixnames($lang = '') { } else if (file_exists($CFG->dataroot .'/lang/'. $lang .'/pix.php')) { $path = $CFG->dataroot .'/lang/'. $lang .'/pix.php'; - } else if ($parentlang = get_string('parentlanguage') and $parentlang != '[[parentlanguage]]') { + } else if ($parentlang = get_parent_language()) { return get_list_of_pixnames($parentlang); //return pixnames from parent language instead } @@ -5879,7 +5891,7 @@ function get_list_of_currencies() { $lang = current_language(); if (!file_exists($CFG->dataroot .'/lang/'. $lang .'/currencies.php')) { - if ($parentlang = get_string('parentlanguage')) { + if ($parentlang = get_parent_language()) { if (file_exists($CFG->dataroot .'/lang/'. $parentlang .'/currencies.php')) { $lang = $parentlang; } else {