Module:urj-fin-headword

From Wiktionary, the free dictionary
Jump to navigation Jump to search
This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

local lang = require("Module:languages").getByCode("urj-fin-pro")

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	local args = frame:getParent().args
	SUBPAGENAME = mw.title.getCurrentTitle().subpageText
	
	local head = args["head"]; if head == "" then head = nil end
	
	-- The part of speech. This is also the name of the category that
	-- entries go in. However, the two are separate (the "cat" parameter)
	-- because you sometimes want something to behave as an adjective without
	-- putting it in the adjectives category.
	local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
	local cat = args["cat"]; if cat == "" then cat = nil end
	
	local inflections = nil
	local categories = {}
	
	if poscat == "verbs" then
		local stem = args[1]
		
		if stem then
			inflections = {{ label = "stem", "*" .. stem .. "-" }}
			if args["stem2"] then
				table.insert(inflections[1], "*" .. args["stem2"] .. "-")
			end
		else
			table.insert(categories, "Proto-Finnic verb stem requests")
		end
	end
	
	local data = {lang = lang, pos_category = cat or poscat, categories = categories, heads = {head}, inflections = inflections}
	
	return require("Module:headword").full_headword(data)
end

return export