Permalink
Browse files

New code to use locale information from language packs if necessary

  • Loading branch information...
1 parent a8b7b66 commit 339bb5599f2730016f52c9703cd2334d0b26aa4e moodler committed Dec 8, 2002
Showing with 16 additions and 8 deletions.
  1. +16 −8 lib/setup.php
View
24 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 @@ class object {};
$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);
+
?>

0 comments on commit 339bb55

Please sign in to comment.