Jump to content

Module:mul-headword

From Wiktionary, the free dictionary


local m_head = require("Module:headword")
local mul = require("Module:languages").getByCode("mul")

local export = {}

local labels = {f = "feminine", n = "neuter"}

local function add_form(data,form,inflected)
	data.inflections = data.inflections or {}
	table.insert(data.inflections, {
		label = labels[form],
		accel = {form = form},
		inflected
	})
end

function export.adjectives(frame)
	local args = frame:getParent().args
	local pagename = args.pagename or mw.title.getCurrentTitle().text
	local infl = args[1]
	local nocat = args.nocat
	local data = {
		lang = mul,
		pagename = pagename,
		pos_category = "adjectives",
	}
	if infl then
		if infl == "~" then
			infl = pagename
		end
		data.genders = {"m"}
		add_form(data,"f",infl.."a")
		add_form(data,"n",infl.."um")
	elseif pagename:sub(-2) == "us" then
		local stem = pagename:sub(1,-3)
		data.genders = {"m"}
		add_form(data,"f",stem.."a")
		add_form(data,"n",stem.."um")
	elseif pagename:sub(-2) == "is" then
		local stem = pagename:sub(1,-3)
		data.genders = {"m", "f"}
		add_form(data,"n",stem.."e")
	else
		data.genders = {"m", "f", "n"}
	end
	return m_head.full_headword(data)
		.. (nocat and "" or "[[Category:Specific epithets]]")
end

function export.show(frame)
	local pos = frame.args[1]
	return export[pos](frame)
end

return export