From 2968dc93c0696dba87d02148cd5ab993a039d728 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 8 May 2008 08:06:47 +0000 Subject: [PATCH] Fixed locale stuff for users, if no valid was set before. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10843 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/functions.inc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index 05877a036..e8b500cb1 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -2366,6 +2366,16 @@ function get_languages($languages_in_own_language = FALSE,$strip_region_tag = FA if($languages_in_own_language){ $old_lang = setlocale(LC_ALL, 0); + + /* If the locale wasn't correclty set before, there may be an incorrect + locale returned. Something like this: + C_CTYPE=de_DE.UTF-8;LC_NUMERIC=C;LC_TIME=de_DE.UTF-8;LC ... + Extract the locale name from this string and use it to restore old locale. + */ + if(preg_match("/LC_CTYPE/",$old_lang)){ + $old_lang = preg_replace("/^.*LC_CTYPE=([^;]*).*$/","\\1",$old_lang); + } + foreach($tmp as $key => $name){ $lang = $key.".UTF-8"; setlocale(LC_ALL, $lang); -- 2.30.2