UNPKG

@manuth/woltlab-compiler

Version:

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

73 lines 2.28 kB
import { LocalizationInstructionCompiler } from "../../../Compilation/PackageSystem/Instructions/LocalizationInstructionCompiler.js"; import { NodeSystemInstruction } from "../NodeSystem/NodeSystemInstruction.js"; /** * Represents an instruction which provides localizations. * * @template TItem * The type of the localization-items. * * @template TOptions * THe type of the options for generating the localization-items. */ export class LocalizationInstruction extends NodeSystemInstruction { /** * Initializes a new instance of the {@link LocalizationInstruction `LocalizationInstruction<TItem, TOptions>`} class. * * @param options * The options for generating the object. * * @param generator * The generator-function for generating sub-nodes. */ constructor(options, generator) { super(options, generator); } /** * @inheritdoc */ get Type() { return LocalizationInstruction.LOCALIZATION_INSTRUCTION_TYPE; } /** * @inheritdoc */ get TranslationDirectory() { return this.FileName; } /** * @inheritdoc */ get Compiler() { return new LocalizationInstructionCompiler(this); } /** * @inheritdoc * * @returns * The messages of the options-instruction. */ GetMessages() { let result = {}; for (let rootNode of this.Nodes) { for (let node of rootNode.GetAllNodes()) { if (node.Item) { for (let locale of node.Item.Translations.GetLocales()) { if (!(locale in result)) { result[locale] = {}; } if (!(rootNode.FullName in result[locale])) { result[locale][rootNode.FullName] = {}; } result[locale][rootNode.FullName][node.FullName] = node.Item.Translations.Data.get(locale); } } } } return result; } } /** * The name of the type of localization instructions. */ LocalizationInstruction.LOCALIZATION_INSTRUCTION_TYPE = "language"; //# sourceMappingURL=LocalizationInstruction.js.map