Hopp til innhald

Modul:category tree/poscatboiler/data/lang-specific

Frå Wiktionary - den frie ordboka

Dokumentasjon for modulen kan opprettast på Modul:category tree/poscatboiler/data/lang-specific/dok

-- This module contains language-specific labels and handlers.

local langs_with_modules = {
	["acw"] = true,
	["afb"] = true,
	["ajp"] = true,
	["ang"] = true,
	["apc"] = true,
	["ar"] = true,
	["ary"] = true,
	["arz"] = true,
	["az"] = true,
	["be"] = true,
	["bg"] = true,
	["cs"] = true,
	["cu"] = true,
	["de"] = true,
	["el"] = true,
	["en"] = true,
	["enm"] = true,
	["es"] = true,
	["eu"] = true,
	["fa"] = true,
	["fi"] = true,
	["goh"] = true,
	["grk-pro"] = true,
	["he"] = true,
	["hi"] = true,
	["ira-pro"] = true,
	["it"] = true,
	["ja"] = true,
	["la"] = true,
	["mk"] = true,
	["mt"] = true,
	["ne"] = true,
	["nl"] = true,
	["nn"] = true,
	["orv"] = true,
	["pt"] = true,
	["ru"] = true,
	["ryu"] = true,
	["sa"] = true,
	["sc"] = true,
	["tl"] = true,
	["uk"] = true,
}


--------------------------- Generic driver handler ----------------------------

local function lang_specific_handler(data)
	if not data.lang then
		return nil
	end
	local langcode = data.lang:getCode()
	if not langs_with_modules[langcode] then
		return nil
	end
	local module = "Module:category tree/poscatboiler/data/lang-specific/" .. data.lang:getCode()
	local labels_and_handlers = require(module)
	if labels_and_handlers.LABELS then
		local retval = labels_and_handlers.LABELS[data.label]
		if retval then
			if retval.umbrella == nil and retval.umbrella_parents == nil then
				retval.umbrella = false
			end
			retval.module = retval.module or module
			return retval
		end
	end
	if labels_and_handlers.HANDLERS then
		for _, handler in ipairs(labels_and_handlers.HANDLERS) do
			local retval, args_handled = handler(data)
			if retval then
				if retval.umbrella == nil and retval.umbrella_parents == nil then
					retval.umbrella = false
				end
				retval.module = retval.module or module
				return retval, args_handled
			end
		end
	end
end

return {LABELS = {}, HANDLERS = {lang_specific_handler}}