Code

Added new function to get available languages.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Aug 2007 09:56:54 +0000 (09:56 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Aug 2007 09:56:54 +0000 (09:56 +0000)
get_languages().
Currently implemented into setup and user/generic plugin.

git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6980 594d385d-05f5-0310-b6e9-bd551577e9d8

include/functions.inc
plugins/personal/generic/class_user.inc
setup/class_setupStep_Language.inc

index d52aa1e23e083f69f537d6575f8e0a59c5a83bac..ab5f5db9d9559d7c97daae9e5727480e6da31204 100644 (file)
@@ -2526,5 +2526,37 @@ function mac2company($mac)
   return ($vendor);
 }
 
+
+function get_languages($languages_in_own_language = FALSE)
+{
+  $tmp = array(
+        "de_DE" => "German",
+        "fr_FR" => "French",
+        "it_IT" => "Italian",
+        "es_ES" => "Spanish",
+        "en_EN" => "English",
+        "nl_NL" => "Dutch",
+        "pl_PL" => "Polish",
+        "sv_SE" => "Swedish",
+        "zh_CN" => "Chinese",
+        "ru_RU" => "Russian");
+
+  $ret = array();
+  if($languages_in_own_language){
+    $old_lang = setlocale(LC_ALL, 0);
+    foreach($tmp as $key => $name){
+      $lang = $key.".UTF-8";
+      setlocale(LC_ALL, $lang);
+      $ret[$key] = _($name);
+    }
+    setlocale(LC_ALL, $old_lang);
+  }else{
+    foreach($tmp as $key => $name){
+      $ret[$key] = _($name);
+    }
+  }
+  return($ret);
+}
+
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index e24e928e034e461dc7495bbfc327e99737c7a7cc..cd87f29ca964a307247d57580f7f76a10b499780 100644 (file)
@@ -261,11 +261,9 @@ class user extends plugin
     $smarty->assign("gender_list", $sex);
 
     /* Assign prefered langage */
-    $language= array(0 => "&nbsp;", "fr_FR" => ("fr_FR"), "en_EN" => ("en_EN"), 
-                                    "de_DE" => ("de_DE"), "it_IT" => ("it_IT"), 
-                                    "nl_NL" => ("nl_NL"), "ru_RU" => ("ru_RU"),
-                                    "zh_CN" => ("zh_CN"), "pl_PL" => ("pl_PL"),
-                                    "sv_SE" => ("sv_SE"), "es_ES" => ("es_ES"));
+
+    
+    $language= array_merge(array(0 => "&nbsp;") ,get_languages());
     $smarty->assign("preferredLanguage_list", $language);
 
     /* Get random number for pictures */
index e5beae6cc741ace293ea5aaf4c73d470d6ae6146..e1b5e72ab61c11b2487740b8afb5063b924d967f 100644 (file)
@@ -44,17 +44,7 @@ class Step_Language extends setup_step
   
   function execute()
   {
-    $this->languages = array(""      => _("Automatic"),
-                             "de_DE" => _("German"),
-                             "fr_FR" => _("French"),
-                             "it_IT" => _("Italian"),
-                             "es_ES" => _("Spanish"),
-                             "en_EN" => _("English"),
-                             "nl_NL" => _("Dutch"),
-                             "pl_PL" => _("Polish"),
-                             "sv_SE" => _("Swedish"),
-                             "zh_CN" => _("Chinese"),
-                             "ru_RU" => _("Russian"));
+    $this->languages = array_merge(array(""      => _("Automatic")),get_languages(TRUE));
     asort($this->languages);
     $smarty = get_smarty();
     $smarty->assign("languages",    $this->languages);