From 4acedbec5338a302d6fefc6b3852a5ca6871117a Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 7 Aug 2007 09:56:54 +0000 Subject: [PATCH] Added new function to get available languages. 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 | 32 +++++++++++++++++++++++++ plugins/personal/generic/class_user.inc | 8 +++---- setup/class_setupStep_Language.inc | 12 +--------- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/include/functions.inc b/include/functions.inc index d52aa1e23..ab5f5db9d 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -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: ?> diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index e24e928e0..cd87f29ca 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -261,11 +261,9 @@ class user extends plugin $smarty->assign("gender_list", $sex); /* Assign prefered langage */ - $language= array(0 => " ", "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 => " ") ,get_languages()); $smarty->assign("preferredLanguage_list", $language); /* Get random number for pictures */ diff --git a/setup/class_setupStep_Language.inc b/setup/class_setupStep_Language.inc index e5beae6cc..e1b5e72ab 100644 --- a/setup/class_setupStep_Language.inc +++ b/setup/class_setupStep_Language.inc @@ -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); -- 2.30.2