woltlab-compiler
Version:
A compiler for WoltLab-Package Archives and WoltLab-Package Components
89 lines • 2.91 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("util");
const BBCodeInstructionCompiler_1 = require("../../../Compilation/PackageSystem/Instructions/BBCodeInstructionCompiler");
const BBCode_1 = require("../../../Customization/BBCodes/BBCode");
const LocalizationNode_1 = require("../../../Globalization/LocalizationNode");
const TranslationInstruction_1 = require("../Globalization/TranslationInstruction");
const NamedDeleteInstruction_1 = require("../NamedDeleteInstruction");
/**
* Represents an instruction which provides bb-codes.
*/
class BBCodeInstruction extends NamedDeleteInstruction_1.NamedDeleteInstruction {
/**
* Initializes a new instance of the `BBCodeInstruction` class.
*/
constructor(options) {
super(options);
/**
* The bb-codes provided by this instruction.
*/
this.bbCodes = [];
/**
* The path to save the translations to. Gets the path to save the translations to.
*/
this.translationDirectory = this.Type;
if (!util_1.isNullOrUndefined(options.TranslationDirectory)) {
this.TranslationDirectory = options.TranslationDirectory;
}
for (let bbCode of options.BBCodes) {
this.BBCodes.push(new BBCode_1.BBCode(bbCode));
}
}
/**
* @inheritdoc
*/
get Type() {
return "bbcode";
}
/**
* Gets the bb-codes provided by this instruction.
*/
get BBCodes() {
return this.bbCodes;
}
/**
* @inheritdoc
*/
get TranslationDirectory() {
return this.translationDirectory;
}
/**
* @inheritdoc
*/
set TranslationDirectory(value) {
this.translationDirectory = value;
}
/**
* @inheritdoc
*/
get Compiler() {
return new BBCodeInstructionCompiler_1.BBCodeInstructionCompiler(this);
}
/**
* @inheritdoc
*/
GetMessages() {
let result = new TranslationInstruction_1.TranslationInstruction({
FileName: this.TranslationDirectory,
Nodes: []
});
let rootNode = new LocalizationNode_1.LocalizationNode({
Name: "wcf.editor.button"
});
for (let bbCode of this.BBCodes) {
if (Object.keys(bbCode.DisplayName).length > 0) {
rootNode.Nodes.push(new LocalizationNode_1.LocalizationNode({
Name: bbCode.Name,
Item: {
Translations: bbCode.DisplayName.Data
}
}));
}
}
result.Nodes.push(rootNode);
return result.GetMessages();
}
}
exports.BBCodeInstruction = BBCodeInstruction;
//# sourceMappingURL=BBCodeInstruction.js.map