]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17565 automatic download of parent lang + parent lang cleanup
authorskodak <skodak>
Sat, 7 Feb 2009 18:55:21 +0000 (18:55 +0000)
committerskodak <skodak>
Sat, 7 Feb 2009 18:55:21 +0000 (18:55 +0000)
install.php
lib/moodlelib.php

index f39e91bb1fe63229fe3b4b938ee1ad81b2038e90..00e7c7979e3b24bda7b6531f4f723bc00191c387 100644 (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();
+                }
+            }
         }
     }
 
index a45b7f8a221d0889e4dfdac9442a43f19de3accd..fd64f76e5a6b7913fa39f1fa745af5e1d769a36f 100644 (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 {