From 4bfa92e714f06cc8da2a8720786beadc9719c233 Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 2 Oct 2002 10:33:05 +0000 Subject: [PATCH] Added new header to all pages to set the current charset, to help browsers --- lib/moodlelib.php | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 2435ed88af..594a30b094 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -39,6 +39,14 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta= $button = "wwwroot/login/index.php\">".get_string("login").""; } } + + // Specify character set ... default is iso-8859-1 but some languages might need something else + // Could be optimised by carrying the charset variable around in $USER + if (current_language() == "en") { + $meta .= "\n"; + } else { + $meta .= "\n"; + } if (!$cache) { // Do everything we can to prevent clients and proxies caching @header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); @@ -46,7 +54,7 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta= $meta .= "\n"; $meta .= "\n"; } - + include ("$CFG->dirroot/theme/$CFG->theme/header.html"); } @@ -1569,6 +1577,16 @@ function print_string($identifier, $module="", $a=NULL) { echo get_string($identifier, $module, $a); } +function current_language() { +// Returns the code for the current language + global $CFG, $USER; + + if (isset($USER->lang)) { // User language can override site language + return $USER->lang; + } else { + return $CFG->lang; + } +} function get_string($identifier, $module="", $a=NULL) { // Return the translated string specified by $identifier as @@ -1579,13 +1597,9 @@ function get_string($identifier, $module="", $a=NULL) { // eg "hello \$a->firstname \$a->lastname" // or "hello \$a" - global $CFG, $USER; + global $CFG; - if (isset($USER->lang)) { // User language can override site language - $lang = $USER->lang; - } else { - $lang = $CFG->lang; - } + $lang = current_language(); if ($module == "") { $module = "moodle"; -- 2.39.5