Code

Fixed locale stuff for users, if no valid was set before.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 8 May 2008 08:06:47 +0000 (08:06 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 8 May 2008 08:06:47 +0000 (08:06 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10843 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/functions.inc

index 05877a0369c1f754896a21bf3adc3bc50753a98a..e8b500cb176921af3a4326f32a30c3ccb86ed351 100644 (file)
@@ -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);