woltlab-compiler
Version:
A compiler for WoltLab-Package Archives and WoltLab-Package Components
64 lines • 2.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("util");
const LocalizationInstructionCompiler_1 = require("../../../Compilation/PackageSystem/Instructions/LocalizationInstructionCompiler");
const NodeSystemInstruction_1 = require("../NodeSystem/NodeSystemInstruction");
/**
* Represents an instruction which provides localizations.
*/
class LocalizationInstruction extends NodeSystemInstruction_1.NodeSystemInstruction {
/**
* Initializes a new instance of the `TranslationInstruction<T>` 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 "language";
}
/**
* @inheritdoc
*/
get TranslationDirectory() {
return this.FileName;
}
/**
* @inheritdoc
*/
get Compiler() {
return new LocalizationInstructionCompiler_1.LocalizationInstructionCompiler(this);
}
/**
* @inheritdoc
*/
GetMessages() {
let result = {};
for (let rootNode of this.Nodes) {
for (let node of rootNode.GetAllNodes()) {
if (!util_1.isNullOrUndefined(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[locale];
}
}
}
}
return result;
}
}
exports.LocalizationInstruction = LocalizationInstruction;
//# sourceMappingURL=LocalizationInstruction.js.map