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"] = "統一",
		["r"] = "Raguileo",
		["n"] = "Nhewenh",
		["a"] = "Azumchefi",
		["?"] = "未知",
	}
	for _, spelling in ipairs(args[1]) do
		local typ = spelling_to_type[spelling]
		if typ then
			table.insert(qualifiers, "[[w:馬普切字母|" .. typ .. "拼寫]]")
			if spelling ~= "?" then
				table.insert(categories, typ .. "馬普切拼寫")
			end
		else
			error("未識別的馬普切字母類型'" .. typ .. "'")
		end
	end

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

return export