From dd9d30a257ac26632e2f7d64cbbbb9e0680ca87f Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Wed, 14 May 2014 17:45:50 -0500 Subject: [PATCH] oops: Fix display of email template set language --- include/class.i18n.php | 16 ++++++++++++++-- include/staff/template.inc.php | 12 +++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/class.i18n.php b/include/class.i18n.php index ecf2f92f6..a06edbae1 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 d168869b9..6eefe948e 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; -- GitLab