Module:arn-headword

From Wiktionary, the free dictionary
Jump to navigation Jump to search

local export = {}

local lang = require("Module:languages").getByCode("arn")

function export.spelling(frame)
	local params = {
		[1] = {list = true, required = true, default = "u"},
	}
	local parargs = frame:getParent().args
	local args = require("Module:parameters").process(parargs, params)
	local qualifiers = {}
	local categories = {}
	local spelling_to_type = {
		["u"] = "Unified",
		["r"] = "Raguileo",
		["n"] = "Nhewenh",
		["a"] = "Azumchefi",
		["?"] = "unknown",
	}
	for _, spelling in ipairs(args[1]) do
		local typ = spelling_to_type[spelling]
		if typ then
			table.insert(qualifiers, "[[w:Mapudungun alphabet|" .. typ .. " spelling]]")
			if spelling ~= "?" then
				table.insert(categories, typ .. " Mapudungun spellings")
			end
		else
			error("Unrecognized Mapugundun alphabet type '" .. typ .. "'")
		end
	end

	return require("Module:qualifier").format_qualifier(qualifiers)
        .. require("Module:utilities").format_categories(categories, lang)
end

return export