Модул:User:kc kennylau/redlinkcat

Документацију овог модула можете да направите на страници Модул:User:kc kennylau/redlinkcat/док

local export = {}

local posname = {
	['n']='nouns', ['v']='verbs', ['a']='adjectives'
}

local inflname = {
	['n']='declension', ['v']='conjugation', ['a']='declension'
}

local function if_not_empty(val)
	return val ~= "" and val
end

function export.show(frame)
	local args = frame:getParent().args
	local langcode = if_not_empty(args[1])
	local pos = if_not_empty(args[2])
	if langcode then
		if pos then
			return maincat(langcode, pos)
		else
			return langcat()
		end
	else
		if pos then
			return poscat()
		else
			return main()
		end
	end
end

function main()
	return "[[Category:Wiktionary maintenance]]"
end

function poscat()
	return "[[Category:Terms with red links in their inflection tables by language|*]]"
end

function langcat()
	return "[[Category:Terms with red links in their inflection tables by language]]"
end

function maincat(langcode, pos)
	mw.log(langcode, require("Module:languages").getByCode(langcode), ('%q'):format(pos))
	local canonicalname = require("Module:languages").getByCode(langcode):getCanonicalName()
	local text = "This category contains " .. canonicalname .. " " .. posname[pos]
	text = text .. " with red links in their " .. inflname[pos] .. " tables."
	text = text .. " This category '''may''' sometimes be empty."
	local poscat = posname[pos]:gsub("^.", string.upper) .. " with red links in their " .. inflname[pos] .. " tables by language"
	local langcat = canonicalname .. " terms with red links in their inflection tables"
	text = text .. "[[Category:" .. poscat .. "]]"
	text = text .. "[[Category:" .. langcat .. "]]"
	text = text .. "__HIDDENCAT__"
	return text
end

return export