Commit 040231b1 authored by Melissa Draper's avatar Melissa Draper Committed by Gerrit Code Review
Browse files

Merge "Split locale-setting code out of current_language function"

parents 8278115f ac4338d7
......@@ -1024,6 +1024,23 @@ function print_object($mixed) {
echo '</pre>';
}
/**
* Reads the locales string from a language pack and attempts to set the current locale
* based on the contents of that string.
*
* @param string $lang
*/
function set_locale_for_language($lang) {
if (empty($lang)) {
return;
}
if ($args = split(',', get_string_location('locales', 'langconfig', array(), 'raw_langstring', $lang))) {
array_unshift($args, LC_ALL);
call_user_func_array('setlocale', $args);
}
}
/**
* This function returns the current
* language to use, either for a given user
......@@ -1066,12 +1083,7 @@ function current_language() {
return $lang;
}
// Set locale. We are probably being called from get_string_location.
// $lang had better be non-empty, or it will call us again.
if ($args = split(',', get_string_location('locales', 'langconfig', array(), 'raw_langstring', $lang))) {
array_unshift($args, LC_ALL);
call_user_func_array('setlocale', $args);
}
set_locale_for_language($lang);
return $lastlang = $lang;
}
......
Supports Markdown
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