Module:Label

From Tsal Wiki
Jump to navigation Jump to search

Documentation for this module may be created at Module:Label/doc

local p = {};

local lcs = require("Module:LanguageCodes").languageCodes

local aliases = {
	["math"] = "mathematics",
	maths = "mathematics",
}

local cm = {
	-- agentive = "agentive intransitive verbs",
	-- patientive = "patientive intransitive verbs",
	-- transitive = "transitive verbs",
	-- ditransitive = "ditransitive verbs",
	chemistry = "chemistry terms",
	informal = "informal terms",
	archaic = "archaic terms",
	financial = "financial terms",
	mathematics = "mathematics terms",
}

local dialects = {
	Bascun = "Bascun Tsal",
}

function p.show(frame)
	mArguments = require('Module:Arguments')
	mTableTools = require('Module:TableTools')
	local args = mArguments.getArgs(frame)
	args = mTableTools.compressSparseArray(args)

	language = lcs[args[1]]
	
	out = "("
	
	for k=2,#args,1 do
		local class_raw = args[k]
		local class = aliases[class_raw] or class_raw
		out = out .. "''" .. class .. "''"
		
		local cat_suffix = cm[class]
		if cat_suffix then
			local cname = language .. " " .. cat_suffix
			out = out .. "[[Category:" .. cname .. "]]"
		else
			local dialect = dialects[class]
			if dialect then
				out = out .. "[[Category:" .. dialect .. "]]"
			end
		end
		
		out = out .. ","
	end
	out = mw.ustring.gsub(out,",$","") .. ')'
	return out
	
end


return p