UNPKG

@manuth/woltlab-compiler

Version:

A compiler for generating WoltLab-Package `.tar` Archives and other WoltLab-Package Components

92 lines 2.77 kB
import { BBCodeInstructionCompiler } from "../../../Compilation/PackageSystem/Instructions/BBCodeInstructionCompiler.js"; import { BBCode } from "../../../Customization/BBCodes/BBCode.js"; import { LocalizationNode } from "../../../Globalization/LocalizationNode.js"; import { TranslationInstruction } from "../Globalization/TranslationInstruction.js"; import { NamedDeleteInstruction } from "../NamedDeleteInstruction.js"; /** * Represents an instruction which provides bb-codes. */ export class BBCodeInstruction extends NamedDeleteInstruction { /** * Initializes a new instance of the {@link BBCodeInstruction `BBCodeInstruction`} class. * * @param options * The options of the bbcode-instruction. */ 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 ((options.TranslationDirectory !== null) && (options.TranslationDirectory !== undefined)) { this.TranslationDirectory = options.TranslationDirectory; } for (let bbCode of options.BBCodes) { this.BBCodes.push(new 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(this); } /** * @inheritdoc * * @returns * The messages of the options-instruction. */ GetMessages() { let result = new TranslationInstruction({ FileName: this.TranslationDirectory, Nodes: [] }); let rootNode = new LocalizationNode({ Name: "wcf.editor.button" }); for (let bbCode of this.BBCodes) { if (Object.keys(bbCode.DisplayName).length > 0) { rootNode.Nodes.push(new LocalizationNode({ Name: bbCode.Name, Item: { Translations: bbCode.DisplayName.ToJSON() } })); } } result.Nodes.push(rootNode); return result.GetMessages(); } } //# sourceMappingURL=BBCodeInstruction.js.map