Skip to content

Commit

Permalink
MDL-44843 try to hack around strict locale names in OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Mar 28, 2014
1 parent ad32dda commit 25ab60b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/moodlelib.php
Expand Up @@ -7665,7 +7665,18 @@ function moodle_setlocale($locale='') {
$messages= setlocale (LC_MESSAGES, 0);
}
// Set locale to all.
setlocale (LC_ALL, $currentlocale);
$result = setlocale (LC_ALL, $currentlocale);
// If setting of locale fails try the other utf8 or utf-8 variant,
// some operating systems support both (Debian), others just one (OSX).
if ($result === false) {
if (stripos($currentlocale, '.UTF-8') !== false) {
$newlocale = str_ireplace('.UTF-8', '.UTF8', $currentlocale);
setlocale (LC_ALL, $newlocale);
} else if (stripos($currentlocale, '.UTF8') !== false) {
$newlocale = str_ireplace('.UTF8', '.UTF-8', $currentlocale);
setlocale (LC_ALL, $newlocale);
}
}
// Set old values.
setlocale (LC_MONETARY, $monetary);
setlocale (LC_NUMERIC, $numeric);
Expand Down

0 comments on commit 25ab60b

Please sign in to comment.