Commit 174dd121 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Waste a bit less time getting current language


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent fdc577b6
......@@ -921,6 +921,13 @@ function print_object($mixed) {
*/
function current_language() {
global $USER, $CFG, $SESSION;
static $lang;
if (!empty($lang)) {
return $lang;
}
if ($USER instanceof User) {
$lang = $USER->get_account_preference('lang');
if ($lang !== null && $lang != 'default') {
......@@ -932,16 +939,16 @@ function current_language() {
}
if (is_a($SESSION, 'Session')) {
$sesslang = $SESSION->get('lang');
if (!empty($sesslang) && $sesslang != 'default') {
return $sesslang;
$lang = $SESSION->get('lang');
if (!empty($lang) && $lang != 'default') {
return $lang;
}
}
if (!empty($CFG->lang)) {
return $CFG->lang;
return $lang = $CFG->lang;
}
return 'en.utf8';
return $lang = 'en.utf8';
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment