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.
This commit is contained in:
parent
20cdb6e0b8
commit
fac3c9f3a6
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue