diff --git a/setup/inc/class.setup_translation.inc.php b/setup/inc/class.setup_translation.inc.php index 1e407be57d..8bf02b0135 100644 --- a/setup/inc/class.setup_translation.inc.php +++ b/setup/inc/class.setup_translation.inc.php @@ -101,22 +101,22 @@ class setup_translation return $ret; } - function get_langs($DEBUG=False) + static function get_langs($DEBUG=False) { return translation::get_langs($DEBUG); } - function drop_langs($appname,$DEBUG=False) + static function drop_langs($appname,$DEBUG=False) { return translation::drop_langs($appname,$DEBUG); } - function add_langs($appname,$DEBUG=False,$force_langs=False) + static function add_langs($appname,$DEBUG=False,$force_langs=False) { return translation::add_langs($appname,$DEBUG,$force_langs); } - function drop_add_all_langs($langs=False) + static function drop_add_all_langs($langs=False) { if (!$langs && !count($langs = translation::get_langs())) { @@ -125,13 +125,60 @@ class setup_translation return translation::install_langs($langs,'dumpold'); } + /** + * Languages we support (alphabetically sorted) + * + * @param boolean $array_values=true true: values are an array, false values are just the descriptiong + * @return array + */ + static function get_supported_langs($array_values=true) + { + $f = fopen(EGW_SERVER_ROOT.'/setup/lang/languages','rb'); + while(($line = fgets($f))) + { + list($lang,$descr) = explode("\t",$line,2); + $lang = trim($lang); + if ($array_values) + { + $languages[$lang]['lang'] = $lang; + $languages[$lang]['descr'] = trim($descr); + $languages[$lang]['available'] = False; + } + else + { + $languages[$lang] = trim($descr); + } + } + fclose($f); + + if ($array_values) + { + $d = dir(EGW_SERVER_ROOT.'/setup/lang'); + while(($file = $d->read())) + { + if(preg_match('/^(php|e)gw_([-a-z]+).lang$/i',$file,$matches)) + { + $languages[$matches[2]]['available'] = True; + } + } + $d->close(); + uasort($languages,create_function('$a,$b','return strcmp(@$a[\'descr\'],@$b[\'descr\']);')); + } + else + { + asort($languages); + } + //_debug_array($languages); + return $languages; + } + /** * List availible charsets and it's supported languages * @param boolean/string $name=false name for selectbox or false to return an array * @param string $selected selected charset * @return string/array html for a selectbox or array with charset / languages pairs */ - function get_charsets($name=false,$selected='') + static function get_charsets($name=false,$selected='') { $charsets = array( 'utf-8' => 'utf-8: '.lang('all languages (incl. not listed ones)'), diff --git a/setup/lang.php b/setup/lang.php index 67a3dfc328..d021d40dfd 100644 --- a/setup/lang.php +++ b/setup/lang.php @@ -55,8 +55,7 @@ if (!@$newinstall && !isset($GLOBALS['egw_info']['setup']['installed_langs'])) } $select_box_desc = lang('Select which languages you would like to use'); $select_box = ''; -$languages = get_langs(); -uasort($languages,create_function('$a,$b','return strcmp(@$a[\'descr\'],@$b[\'descr\']);')); +$languages = setup_translation::get_supported_langs(); foreach($languages as $id => $data) { $select_box_langs =