Gaan na inhoud

Module:category tree/poscatboiler/data

Vanuit Wiktionary, die vrye woordeboek.

Dokumentasie vir hierdie module kan geskep word by: Module:category tree/poscatboiler/data/doc

local labels = {}
local handlers = {}

local subpages = {
	"entry maintenance",
	"figures of speech",
	"lemmas",
	"miscellaneous",
	"names",
	"nie-lemmavorme",
	"phrases",
	"rhymes",
	"shortenings",
	"symbols",
	"templates",
	"terme volgens etimologie",
	"terme volgens leksikale eienskap",
	"terms by semantic function",
	"terms by script",
	"terms by usage",
	"words by number of syllables",
	}

-- Import subpages
for _, subpage in ipairs(subpages) do
	local datamodule = "Module:category tree/poscatboiler/data/" .. subpage
	local retval = require(datamodule)
	if not retval["LABELS"] then
		retval = {LABELS = retval}
	end
	for key, data in pairs(retval["LABELS"]) do
		assert(not labels[key], "Duplicate label: " .. key)
		data.edit = datamodule
		labels[key] = data
	end
	if retval["HANDLERS"] then
		for _, handler in ipairs(retval["HANDLERS"]) do
			table.insert(handlers, { module = datamodule, handler = handler })
		end
	end
end

-- Add child categories to their parents
for key, data in pairs(labels) do
	if data.parents then
		for _, parent in ipairs(data.parents) do
			if type(parent) == "table" then
				if parent.name and not parent.template and not parent.name:find("^Kategorie:") then
					if labels[parent.name].children then
						table.insert(labels[parent.name].children, {name = key, sort = parent.sort})
					else
						labels[parent.name].children = {{name = key, sort = parent.sort}}
					end
				end
			else
				if not parent:find("^Kategorie:") and labels[parent] then
					if labels[parent].children then
						table.insert(labels[parent].children, key)
					else
						labels[parent].children = {key}
					end
				end
			end
		end
	end
end

return {LABELS = labels, HANDLERS = handlers}