@manuth/woltlab-compiler
Version:
A compiler for generating WoltLab-Package `.tar` Archives and other WoltLab-Package Components
51 lines • 1.65 kB
JavaScript
import { XMLEditor } from "../../Serialization/XMLEditor.js";
import { WoltLabXMLCompiler } from "../WoltLabXMLCompiler.js";
/**
* Provides the functionality to compile localization-files.
*/
export class LocalizationFileCompiler extends WoltLabXMLCompiler {
/**
* Initializes a new instance of the {@link LocalizationFileCompiler `LocalizationFileCompiler`} class.
*
* @param item
* The item to compile.
*/
constructor(item) {
super(item);
}
/**
* @inheritdoc
*/
get TagName() {
return "language";
}
/**
* @inheritdoc
*/
get SchemaLocation() {
return "http://www.woltlab.com/XSD/tornado/language.xsd";
}
/**
* @inheritdoc
*
* @returns
* The serialized document.
*/
CreateDocument() {
let document = super.CreateDocument();
let editor = new XMLEditor(document.documentElement);
editor.SetAttribute("languagecode", this.Item[0]);
for (let categoryName of Object.keys(this.Item[1])) {
let categoryElement = editor.CreateElement("category");
categoryElement.SetAttribute("name", categoryName);
editor.Add(categoryElement);
for (let messageName of Object.keys(this.Item[1][categoryName])) {
let itemElement = categoryElement.CreateCDATAElement("item", this.Item[1][categoryName][messageName]);
itemElement.SetAttribute("name", messageName);
categoryElement.Add(itemElement);
}
}
return document;
}
}
//# sourceMappingURL=LocalizationFileCompiler.js.map