commit e46f90f1f4a9e23e9411a947f5285203c30feebb
Author: Alastair Munro <alastair.munro@totaralms.com>
Date:   Wed Oct 19 15:27:56 2011 +1300

    T-9435 lib/moodlelib.php: Fix get_string to correctly find strings in parent language
    
    Change-Id: I14f974784a02ac78235c32c9ff4efb14b663239c

diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index 466530d..760c7c8 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@@ -5617,25 +5617,29 @@ 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)) {   // found the parent lang!
 
-                    //first, see if there's a local file for parent
-                    $locallangfile = $location.$parentlang.'_local'.'/'.$module.'.php';
-                    if (file_exists($locallangfile)) {
-                        if ($result = get_string_from_file($identifier, $locallangfile, "\$resultstring")) {
-                            if (eval($result) === FALSE) {
-                                trigger_error('Lang error: '.$identifier.':'.$locallangfile, E_USER_NOTICE);
+                    // Loop through all the locations again to find
+                    // the actual lang string
+                    foreach ($locations as $loc) {
+                        //first, see if there's a local file for parent
+                        $locallangfile = $loc.$parentlang.'_local'.'/'.$module.'.php';
+                        if (file_exists($locallangfile)) {
+                            if ($result = get_string_from_file($identifier, $locallangfile, "\$resultstring")) {
+                                if (eval($result) === FALSE) {
+                                    trigger_error('Lang error: '.$identifier.':'.$locallangfile, E_USER_NOTICE);
+                                }
+                                return $resultstring;
                             }
-                            return $resultstring;
                         }
-                    }
 
-                    //if local directory not found, or particular string does not exist in local direcotry
-                    $langfile = $location.$parentlang.'/'.$module.'.php';
-                    if (file_exists($langfile)) {
-                        if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) {
-                            eval($result);
-                            return $resultstring;
+                        //if local directory not found, or particular string does not exist in local direcotry
+                        $langfile = $loc.$parentlang.'/'.$module.'.php';
+                        if (file_exists($langfile)) {
+                            if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) {
+                                eval($result);
+                                return $resultstring;
+                            }
                         }
                     }
                 }
