MDL-17565 automatic download of parent lang + parent lang cleanup

This commit is contained in:
skodak
2009-02-07 18:55:21 +00:00
parent 9ace50944f
commit cc8727451f
2 changed files with 23 additions and 4 deletions
+7
View File
@@ -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();
}
}
}
}
+16 -4
View File
@@ -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 {