'groupIDs' => $this->groupIDs,
'optionTree' => $this->optionTree,
'availableGroups' => $this->getAvailableGroups(),
- 'availableLanguages' => $this->getAvailableLanguages(),
+ 'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),
'languageID' => $this->languageID,
'visibleLanguages' => $this->visibleLanguages,
- 'availableContentLanguages' => $this->getAvailableContentLanguages(),
+ 'availableContentLanguages' => LanguageFactory::getInstance()->getContentLanguages(),
'action' => 'add'
));
}
return UserGroup::getAccessibleGroups(array(), array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS));
}
- /**
- * Returns a list of all available languages.
- *
- * @return array
- */
- protected function getAvailableLanguages() {
- $availableLanguages = array();
- foreach (LanguageFactory::getInstance()->getAvailableLanguages(PACKAGE_ID) as $language) {
- $availableLanguages[$language['languageID']] = WCF::getLanguage()->get('wcf.global.language.'.$language['languageCode']);
- }
-
- // sort languages
- StringUtil::sort($availableLanguages);
-
- return $availableLanguages;
- }
-
- /**
- * Returns a list of all available content languages.
- *
- * @return array
- */
- public static function getAvailableContentLanguages() {
- $availableLanguages = array();
- foreach (LanguageFactory::getInstance()->getAvailableContentLanguages(PACKAGE_ID) as $language) {
- $availableLanguages[$language['languageID']] = WCF::getLanguage()->get('wcf.global.language.'.$language['languageCode']);
- }
-
- // sort languages
- StringUtil::sort($availableLanguages);
-
- return $availableLanguages;
- }
-
/**
* Returns the default-form language id
*
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\event\EventHandler;
use wcf\system\exception\UserInputException;
+use wcf\system\language\LanguageFactory;
use wcf\system\wcf;
use wcf\util\ArrayUtil;
use wcf\util\HeaderUtil;
'languageIDs' => $this->languageIDs,
'optionTree' => $this->optionTree,
'availableGroups' => $this->getAvailableGroups(),
- 'availableLanguages' => $this->getAvailablelanguages(),
+ 'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),
'invertGroupIDs' => $this->invertGroupIDs,
'sortField' => $this->sortField,
'sortOrder' => $this->sortOrder,
use wcf\system\event\EventHandler;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
+use wcf\system\language\LanguageFactory;
use wcf\util\ArrayUtil;
use wcf\util\StringUtil;
// data
public $availableGroups = array();
- public $availableLanguages = array();
public $options = array();
public $availableActions = array('sendMail', 'exportMailAddress', 'assignToGroup', 'delete');
public $affectedUsers = 0;
}
$this->availableGroups = $this->getAvailableGroups();
- $this->availableLanguages = $this->getAvailableLanguages();
foreach ($this->activeOptions as $name => $option) {
if (isset($this->values[$name])) {
'languageIDArray' => $this->languageIDArray,
'invertGroupIDs' => $this->invertGroupIDs,
'availableGroups' => $this->availableGroups,
- 'availableLanguages' => $this->availableLanguages,
+ 'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),
'options' => $this->options,
'availableActions' => $this->availableActions,
// assign to group
/**
* @see wcf\page\MultipleLinkPage::$objectListClassName
- */
+ */
public $objectListClassName = 'wcf\data\cronjob\CronjobList';
/**
throw new SystemException("missing attribute 'languagecode' in language file");
}
+ /**
+ * Takes an XML object and returns the specific language name.
+ *
+ * @param wcf\util\XML $xml
+ * @return string language name
+ */
+ public static function readLanguageNameFromXML(XML $xml) {
+ $rootNode = $xml->xpath()->query('/ns:language')->item(0);
+ $attributes = $xml->xpath()->query('attribute::*', $rootNode);
+ foreach ($attributes as $attribute) {
+ if ($attribute->name == 'languagename') {
+ return $attribute->value;
+ }
+ }
+
+ throw new SystemException("missing attribute 'languagename' in language file");
+ }
+
/**
* Imports language items from an XML file into a new or a current language.
* Updates the relevant language files automatically.
// create new language
if ($language === null) {
+ $languageName = self::readLanguageNameFromXML($xml);
$language = self::create(array(
- 'languageCode' => $languageCode
+ 'languageCode' => $languageCode,
+ 'languageName' => $languageName
));
}
<?php
namespace wcf\system\language;
use wcf\data\language\Language;
+use wcf\data\DatabaseObject;
use wcf\system\cache\CacheHandler;
use wcf\system\template\TemplateScriptingCompiler;
use wcf\system\SingletonFactory;
return $this->languages[$languageID];
}
+ /**
+ * Returns an instance of Language or NULL for a given language code.
+ *
+ * @param string $languageCode
+ * @return wcf\data\language\Language
+ */
+ public function getLanguageByCode($languageCode) {
+ // called within WCFSetup
+ if ($this->cache === false || !count($this->cache['codes'])) {
+ $sql = "SELECT languageID
+ FROM wcf".WCF_N."_language
+ WHERE languageCode = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array($languageCode));
+ $row = $statement->fetchArray();
+ if (isset($row['languageID'])) return new Language($row['languageID']);
+ }
+ else if (isset($this->cache['codes'][$languageCode])) {
+ return $this->getLanguage($this->cache['codes'][$languageCode]);
+ }
+
+ return null;
+ }
+
/**
* Returns true if the language category with the given name exists.
*
protected function findPreferredLanguage() {
// get available language codes
$availableLanguageCodes = array();
- foreach ($this->getAvailableLanguages(PACKAGE_ID) as $language) {
- $availableLanguageCodes[] = $language['languageCode'];
+ foreach ($this->getLanguages(PACKAGE_ID) as $language) {
+ $availableLanguageCodes[] = $language->languageCode;
}
// get default language
return $defaultLanguageCode;
}
- /**
- * Returns infos (code, id, encoding, etc) about all available languages
- * for package with the given id.
- *
- * @param integer $packageID
- * @return array
- */
- public function getAvailableLanguages($packageID = PACKAGE_ID) {
- // get list of all available languages
- $availableLanguages = array();
- if (isset($this->cache['packages'][$packageID])) {
- foreach ($this->cache['packages'][$packageID] as $availableLanguageID) {
- $availableLanguages[] = $this->cache['languages'][$availableLanguageID];
- }
- }
- return $availableLanguages;
- }
-
- /**
- * Returns an instance of Language or NULL for a given language code.
- *
- * @param string $languageCode
- * @return wcf\data\language\Language
- */
- public function getLanguageByCode($languageCode) {
- // called within WCFSetup
- if ($this->cache === false || !count($this->cache['codes'])) {
- $sql = "SELECT languageID
- FROM wcf".WCF_N."_language
- WHERE languageCode = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($languageCode));
- $row = $statement->fetchArray();
- if (isset($row['languageID'])) return new Language($row['languageID']);
- }
- else if (isset($this->cache['codes'][$languageCode])) {
- return $this->getLanguage($this->cache['codes'][$languageCode]);
- }
-
- return null;
- }
-
/**
* Returns the active scripting compiler object.
*
return $this->cache['default'];
}
+ /**
+ * Returns all available languages for package with the given id.
+ *
+ * @param integer $packageID
+ * @return array<wcf\data\language\Language>
+ */
+ public function getLanguages($packageID = PACKAGE_ID) {
+ // get list of all available languages
+ $availableLanguages = array();
+ if (isset($this->cache['packages'][$packageID])) {
+ foreach ($this->cache['packages'][$packageID] as $availableLanguageID) {
+ $availableLanguages[$availableLanguageID] = $this->getLanguage($availableLanguageID);
+ }
+ }
+
+ DatabaseObject::sort($availableLanguages, 'languageName');
+ return $availableLanguages;
+ }
+
/**
* Returns all available content languages for given package.
*
* @param integer $packageID
- * @return array $availableLanguages infos about each language (code, id, encoding, etc)
+ * @return array<wcf\data\language\Language>
*/
- public function getAvailableContentLanguages($packageID = PACKAGE_ID) {
+ public function getContentLanguages($packageID = PACKAGE_ID) {
$availableLanguages = array();
if (isset($this->cache['packages'][$packageID])) {
foreach ($this->cache['packages'][$packageID] as $availableLanguageID) {
if ($this->cache['languages'][$availableLanguageID]['hasContent']) {
- $availableLanguages[$availableLanguageID] = $this->cache['languages'][$availableLanguageID];
+ $availableLanguages[$availableLanguageID] = $this->getLanguage($availableLanguageID);
}
}
}
+ DatabaseObject::sort($availableLanguages, 'languageName');
return $availableLanguages;
}
// rebuild language cache
$this->clearCache();
}
-
- /**
- * Returns an ordered list of the names of all installed languages in the
- * active language.
- *
- * @return array<string>
- */
- public function getLanguages() {
- $languages = array();
- foreach ($this->cache['codes'] as $languageCode => $languageID) {
- $languages[$languageID] = WCF::getLanguage()->getDynamicVariable('wcf.global.language.'.$languageCode);
- }
-
- StringUtil::sort($languages);
- return $languages;
- }
-
- /**
- * Returns an ordered list of all installed language codes.
- *
- * @return array<string>
- */
- public function getLanguageCodes() {
- $languageCodes = array();
- foreach ($this->cache['codes'] as $languageCode => $languageID) {
- $languageCodes[$languageID] = $languageCode;
- }
-
- StringUtil::sort($languageCodes);
- return $languageCodes;
- }
}
<?xml version="1.0" encoding="UTF-8"?>
-<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="de-informal">
+<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="de-informal" languagename="Deutsch (Du)">
<category name="wcf.acp">
<item name="wcf.acp"><![CDATA[Administrationsoberfläche]]></item>
<item name="wcf.acp.help"><![CDATA[Hilfe]]></item>
<?xml version="1.0" encoding="UTF-8"?>
-<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="de">
+<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="de" languagename="Deutsch">
<category name="wcf.acp.cronjob">
<item name="wcf.acp.cronjob.list"><![CDATA[Zeitgesteuerte Aufgaben]]></item>
<item name="wcf.acp.cronjob.add"><![CDATA[Zeitgesteuerte Aufgabe hinzufügen]]></item>
<item name="wcf.global.form.edit.success"><![CDATA[Ihre Änderungen wurden erfolgreich gespeichert.]]></item>
<item name="wcf.global.form.add.success"><![CDATA[Der Eintrag wurde erfolgreich gespeichert.]]></item>
<item name="wcf.global.loading"><![CDATA[Lädt …]]></item>
+ <item name="wcf.global.button.next"><![CDATA[Weiter »]]></item>
+ <item name="wcf.global.sortOrder.ascending"><![CDATA[in aufsteigender Reihenfolge]]></item>
+ <item name="wcf.global.sortOrder.descending"><![CDATA[in absteigender Reihenfolge]]></item>
+ <item name="wcf.global.button.back"><![CDATA[« Zurück]]></item>
+ <item name="wcf.global.button.collapsible"><![CDATA[Auf- und Zuklappen]]></item>
+ <item name="wcf.global.page.next"><![CDATA[nächste Seite]]></item>
+ <item name="wcf.global.page.previous"><![CDATA[vorherige Seite]]></item>
</category>
<category name="wcf.user">
<?xml version="1.0" encoding="UTF-8"?>
-<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="en">
+<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="en" languagename="English">
<category name="wcf.acp">
<item name="wcf.acp"><![CDATA[Administration Control Panel]]></item>
<item name="wcf.acp.help"><![CDATA[Help]]></item>
CREATE TABLE wcf1_language (
languageID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
languageCode VARCHAR(20) NOT NULL DEFAULT '',
+ languageName VARCHAR(255) NOT NULL DEFAULT '',
isDefault TINYINT(1) NOT NULL DEFAULT 0,
hasContent TINYINT(1) NOT NULL DEFAULT 0,
UNIQUE KEY languageCode (languageCode)