mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 00:42:54 +02:00
MDL-8777 Failing setup_lang_from_browser if lang contains dash
This commit is contained in:
parent
d67de0ca05
commit
279948083b
@ -6787,13 +6787,14 @@ function setup_lang_from_browser() {
|
||||
}
|
||||
|
||||
/// Extract and clean langs from headers
|
||||
$langs = strtolower(clean_param($_SERVER['HTTP_ACCEPT_LANGUAGE'], PARAM_CLEAN)); /// Get String with basic clean
|
||||
$langs = strtolower(clean_param($_SERVER['HTTP_ACCEPT_LANGUAGE'], PARAM_SAFEDIR)); /// Get String with basic clean
|
||||
$langs = str_replace('-', '_', $langs); // we are using underscores
|
||||
$langs = explode(',', $langs); /// Convert to array
|
||||
$langs = preg_replace('/([a-z]{2,3}).*/','$1_utf8', $langs); ///Convert to Moodle langs
|
||||
$langs = array_unique($langs); /// Avoid duplicates
|
||||
|
||||
/// Look for such langs under standard locations
|
||||
foreach ($langs as $lang) {
|
||||
$lang = $lang.'_utf8';
|
||||
if (file_exists($CFG->dataroot .'/lang/'. $lang) or file_exists($CFG->dirroot .'/lang/'. $lang)) {
|
||||
$SESSION->lang = $lang; /// Lang exists, set it in session
|
||||
break; /// We have finished. Go out
|
||||
|
Loading…
x
Reference in New Issue
Block a user