]> git.mjollnir.org Git - moodle.git/commitdiff
New code to use locale information from language packs if necessary
authormoodler <moodler>
Sun, 8 Dec 2002 17:26:21 +0000 (17:26 +0000)
committermoodler <moodler>
Sun, 8 Dec 2002 17:26:21 +0000 (17:26 +0000)
lib/setup.php

index 488ee0fc460289e5b99b6364d4b045d7e0937f28..856499324c5d0ad62098613a84d25acb116fdc13 100644 (file)
     require("$CFG->dirroot/theme/$CFG->theme/config.php");
 
 
-/// Set language/locale of printed times etc (must be supported by OS)
-
-    if (!$CFG->locale) {
-        $CFG->locale = $CFG->lang; // Might work
-    }
-    setlocale (LC_TIME, $CFG->locale);
-    setlocale (LC_CTYPE, $CFG->locale);
-    setlocale (LC_COLLATE, $CFG->locale);
 
 /// Reference code to remove magic quotes from everything ... just in case.
 /// If you have problems with slashes everywhere then you might want to 
     $ME     = strip_querystring($FULLME);
 
 
+/// Set language/locale of printed times.  If user has chosen a language that 
+/// that is different from the site language, then use the locale specified 
+/// in the language file.  Otherwise, if the admin hasn't specified a locale
+/// then use the one from the default language.  Otherwise (and this is the 
+/// majority of cases), use the stored locale specified by admin.
+
+    if ($USER->lang and ($USER->lang != $CFG->lang) ) {
+        $CFG->locale = get_string("locale");
+    } else if (!$CFG->locale) {
+        $CFG->locale = get_string("locale");
+        set_config("locale", $CFG->locale);   // cache it to save lookups in future
+    }
+    setlocale (LC_TIME, $CFG->locale);
+    setlocale (LC_CTYPE, $CFG->locale);
+    setlocale (LC_COLLATE, $CFG->locale);
+
 ?>