From fac3c9f3a66579cfe62ca3c2dc7349e8f6e8922d Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 25 Jun 2014 11:43:15 +0200 Subject: [PATCH] Util\Translator: fix language list Reverted former redundant patch, got confused by legacy web modules been translated with earlier versions. They had a different directory structure and registered erraneous domain directories. This patch fixes the list, does an additional safety check (dirname must end with .UTF-8) and strips .UTF-8 from the locale name. Former regex matched always and therefore blacklisted every translation. --- library/Icinga/Util/Translator.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/Icinga/Util/Translator.php b/library/Icinga/Util/Translator.php index 8d6e60e19..89f74f76a 100644 --- a/library/Icinga/Util/Translator.php +++ b/library/Icinga/Util/Translator.php @@ -131,16 +131,17 @@ class Translator public static function getAvailableLocaleCodes() { $codes = array(); - + $postfix = '.UTF-8'; foreach (array_values(self::$knownDomains) as $directory) { $dh = opendir($directory); while (false !== ($name = readdir($dh))) { - if (!preg_match('@\.|\.\.@', $name) && is_dir($directory . DIRECTORY_SEPARATOR . $name)) { - $codes[] = $name; + if (substr($name, 0, 1) === '.') continue; + if (substr($name, -6) !== $postfix) continue; + if (is_dir($directory . DIRECTORY_SEPARATOR . $name)) { + $codes[] = substr($name, 0, -6); } } } - return $codes; } }