throw new SystemException("missing attribute 'languagename' in language file");
}
+ /**
+ * Takes an XML object and returns the specific country code.
+ *
+ * @param wcf\util\XML $xml
+ * @return string country code
+ */
+ public static function readCountryCodeFromXML(XML $xml) {
+ $rootNode = $xml->xpath()->query('/ns:language')->item(0);
+ $attributes = $xml->xpath()->query('attribute::*', $rootNode);
+ foreach ($attributes as $attribute) {
+ if ($attribute->name == 'countrycode') {
+ return $attribute->value;
+ }
+ }
+
+ throw new SystemException("missing attribute 'countrycode' 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) {
+ $countryCode = self::readCountryCodeFromXML($xml);
$languageName = self::readLanguageNameFromXML($xml);
$language = self::create(array(
+ 'countryCode' => $countryCode,
'languageCode' => $languageCode,
'languageName' => $languageName
));
public function getData(array $cacheResource) {
$data = array(
'codes' => array(),
+ 'countryCodes' => array(),
'languages' => array(),
'packages' => array(),
'default' => 0,
// language code to language id
$data['codes'][$language->languageCode] = $language->languageID;
+
+ // country code to language id
+ $data['countryCode'][$language->languageID] = $language->countryCode;
}
// get language categories
<?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" languagename="Deutsch">
+<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" countrycode="de">
<category name="wcf.acp.cronjob">
<item name="wcf.acp.cronjob.list"><![CDATA[Cronjobs]]></item>
<item name="wcf.acp.cronjob.add"><![CDATA[Cronjob hinzufügen]]></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="en" languagename="English">
+<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" countrycode="gb">
<category name="wcf.acp.cronjob">
<item name="wcf.acp.cronjob.list"><![CDATA[Cron jobs]]></item>
<item name="wcf.acp.cronjob.add"><![CDATA[Add a new cron job]]></item>
languageID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
languageCode VARCHAR(20) NOT NULL DEFAULT '',
languageName VARCHAR(255) NOT NULL DEFAULT '',
+ countryCode VARCHAR(10) NOT NULL DEFAULT '',
isDefault TINYINT(1) NOT NULL DEFAULT 0,
hasContent TINYINT(1) NOT NULL DEFAULT 0,
UNIQUE KEY languageCode (languageCode)