@manuth/woltlab-compiler
Version:
A compiler for generating WoltLab-Package `.tar` Archives and other WoltLab-Package Components
52 lines • 1.69 kB
JavaScript
import { LocalizationNode } from "../../../Globalization/LocalizationNode.js";
import { TranslationInstruction } from "./TranslationInstruction.js";
/**
* Represents an instruction which provides translations.
*/
export class ErrorMessageInstruction extends TranslationInstruction {
/**
* Initializes a new instance of the {@link ErrorMessageInstruction `ErrorMessageInstruction`} class.
*
* @param options
* The options of the error-message.
*/
constructor(options) {
super(options);
}
/**
* @inheritdoc
*
* @returns
* The messages of the options-instruction.
*/
GetMessages() {
let result = new TranslationInstruction({
FileName: null,
Nodes: []
});
let optionNode = new LocalizationNode({
Name: "wcf.acp.option"
});
let errorNode = new LocalizationNode({
Name: "error"
});
for (let rootNode of this.Nodes) {
for (let node of rootNode.GetAllNodes()) {
if (node.Item) {
if (node.Item.Translations.GetLocales().length > 0) {
errorNode.Nodes.push(new LocalizationNode({
Name: node.FullName,
Item: {
Translations: node.Item.Translations.ToJSON()
}
}));
}
}
}
}
optionNode.Nodes.push(errorNode);
result.Nodes.push(optionNode);
return result.GetMessages();
}
}
//# sourceMappingURL=ErrorMessageInstruction.js.map