diff options
| author | fisharebest <fisharebest@gmail.com> | 2010-12-09 15:31:27 +0000 |
|---|---|---|
| committer | fisharebest <fisharebest@gmail.com> | 2010-12-09 15:31:27 +0000 |
| commit | 3a77871a994cc99359a1488146907eb657b54ea7 (patch) | |
| tree | 1b0574f7ee5e68c8ee3938344f26b2fb69f3fb51 | |
| parent | 4eebf8a84806329da093d84887439bcf0b80699d (diff) | |
| download | webtrees-3a77871a994cc99359a1488146907eb657b54ea7.tar.gz webtrees-3a77871a994cc99359a1488146907eb657b54ea7.tar.bz2 webtrees-3a77871a994cc99359a1488146907eb657b54ea7.zip | |
Fix: zh_CN not appearing in language list.
| -rw-r--r-- | includes/classes/class_i18n.php | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/includes/classes/class_i18n.php b/includes/classes/class_i18n.php index 84cfb0f322..de307ebc37 100644 --- a/includes/classes/class_i18n.php +++ b/includes/classes/class_i18n.php @@ -147,37 +147,39 @@ class i18n { // Check which languages are installed static public function installed_languages() { - //if (isset($_SESSION['installed_languages'])) { - //return $_SESSION['installed_languages']; - //} else - { - $_SESSION['installed_languages']=array(); + static $installed_languages; + if (!is_array($installed_languages)) { + $installed_languages=array(); $d=opendir(WT_ROOT.'language'); while (($f=readdir($d))!==false) { - if (preg_match('/^(([a-z][a-z][a-z]?)(@[a-z]+|_[A-Z][A-Z])?)\.mo$/', $f, $match)) { - // TODO: gettext() and ZF use different standards for locale names :-( - if ($match[1]=='sr@latin' || $match[1]=='zh_CN') { - // TODO: - continue; - } + if (preg_match('/^(([a-z][a-z][a-z]?)(_[A-Z][A-Z])?)\.mo$/', $f, $match)) { + // launchpad does not support language variants such as sr@latin. + // Until it does, we cannot support variants such as sr@latin + // Sort by the transation of the base language, then the variant. // e.g. English|British English, Portuguese|Brazilian Portuguese - $_SESSION['installed_languages'][$match[1]]= + $installed_languages[$match[1]]= Zend_Locale::getTranslation($match[2], 'language', $match[2]).'|'. Zend_Locale::getTranslation($match[1], 'language', $match[1]); } } closedir($d); - if (empty($_SESSION['installed_languages'])) { + if (empty($installed_languages)) { die('There are no lanuages installed. You must include at least one xx.mo file in /language/'); } // Sort by the combined language/language name... - uasort($_SESSION['installed_languages'], 'utf8_strcasecmp'); - foreach ($_SESSION['installed_languages'] as &$value) { - list(,$value)=explode('|', $value); + uasort($installed_languages, 'utf8_strcasecmp'); + foreach ($installed_languages as &$value) { + // The locale database doesn't have translations for certain + // "default" languages, such as zn_CH. + if (substr($value, -1)=='|') { + $value=rtrim($value, '|'); + } else { + list(,$value)=explode('|', $value); + } } - return $_SESSION['installed_languages']; } + return $installed_languages; } // Generate i18n markup for the <html> tag, e.g lang="ar" dir="RTL" |
