summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/classes/class_i18n.php36
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"