Module:tln-headword

Revision as of 19:11, 18 June 2026 by Nehster9 (talk | contribs)


local export = {}
local pos_functions = {}

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

local PAGENAME = mw.title.getCurrentTitle().text

-- Nouns
pos_functions.nouns = function(class, args, data)
	local params = {
		[1] = {required = true}, -- gender
		["pl"] = {},
		["head"] = {},
		["tr"] = {},
		["pltr"] = {},
	}

	local args = require("Module:parameters").process(args, params)

	local head = args.head or PAGENAME

	data.lang = lang
	data.heads = {head}
	data.genders = {args[1]}
	data.inflections = {}

	-- plural handling
	if args.pl then
		local infl = {
			label = "plural",
			{ term = args.pl }
		}

		if args.pltr then
			infl[1].tr = args.pltr
		end

		table.insert(data.inflections, infl)
	end

	if args.tr then
		data.translits = {args.tr}
	end
end

-- Entry point
function export.show(frame)
	local parent_args = frame:getParent().args

	local poscat = frame.args[1] or "nouns"

	local data = {
		inflections = {},
		genders = {},
		categories = {},
	}

	if pos_functions[poscat] then
		pos_functions[poscat](nil, parent_args, data)
	end

	return require("Module:headword").full_headword(data)
end

return export