From 339bb5599f2730016f52c9703cd2334d0b26aa4e Mon Sep 17 00:00:00 2001 From: moodler Date: Sun, 8 Dec 2002 17:26:21 +0000 Subject: [PATCH] New code to use locale information from language packs if necessary --- lib/setup.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index 488ee0fc46..856499324c 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -65,14 +65,6 @@ 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 @@ -123,4 +115,20 @@ $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); + ?> -- 2.39.5