diff --git a/include/class.i18n.php b/include/class.i18n.php index ecf2f92f653cbf059a4469507843d6553c5fba38..a06edbae1319a0e9b314b476111aa3e6afe466ea 100644 --- a/include/class.i18n.php +++ b/include/class.i18n.php @@ -157,7 +157,19 @@ class Internationalization { } } + static function getLanguageDescription($lang) { + $langs = self::availableLanguages(); + $lang = strtolower($lang); + if (isset($langs[$lang])) + return $langs[$lang]['desc']; + else + return $lang; + } + static function availableLanguages($base=I18N_DIR) { + static $cache = false; + if ($cache) return $cache; + $langs = (include I18N_DIR . 'langs.php'); // Consider all subdirectories and .phar files in the base dir @@ -182,9 +194,9 @@ class Internationalization { ); } } - usort($installed, function($a, $b) { return strcasecmp($a['code'], $b['code']); }); + uasort($installed, function($a, $b) { return strcasecmp($a['code'], $b['code']); }); - return $installed; + return $cache = $installed; } // TODO: Move this to the REQUEST class or some middleware when that diff --git a/include/staff/template.inc.php b/include/staff/template.inc.php index d168869b94884133347db5109b8c86ce959786fe..6eefe948edb971c701744af16da066083e0a103d 100644 --- a/include/staff/template.inc.php +++ b/include/staff/template.inc.php @@ -64,15 +64,9 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); <td width="180" class="required"> Language: </td> - <td> - <?php - $langs = Internationalization::availableLanguages(); - $lang = strtolower($info['lang']); - if (isset($langs[$lang])) - echo $langs[$lang]['desc']; - else - echo $info['lang']; ?> - </td> + <td><?php + echo Internationalization::getLanguageDescription($info['lang']); + ?></td> </tr> <?php $current_group = false;