Bu modul uchun Modul:rup-headword/doc nomli hujjat sahifasini yaratishingiz mumkin

local export = {}
local pos_functions = {}

local force_cat = false -- for testing; if true, categories appear in non-mainspace pages

local lang = require("Module:languages").getByCode("rup")
local langname = "Aromanian"

local function track(track_id)
	require("Module:debug/track")("rup-headword/" .. track_id)
	return true
end

local function glossary_link(anchor, text)
	text = text or anchor
	return "[[Appendix:Glossary#" .. anchor .. "|" .. text .. "]]"
end

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	local iparams = {
		[1] = {required = true},
		["def"] = {},
	}
	local iargs = require("Module:parameters").process(frame.args, iparams)
	local args = frame:getParent().args
	local poscat = iargs[1]
	local def = iargs.def

	local parargs = frame:getParent().args

	local params = {
		["head"] = {list = true},
		["id"] = {},
		["sort"] = {},
		["splithyph"] = {type = "boolean"},
		["nolinkhead"] = {type = "boolean"},
		["json"] = {type = "boolean"},
		["pagename"] = {}, -- for testing
	}

	if pos_functions[poscat] then
		for key, val in pairs(pos_functions[poscat].params) do
			params[key] = val
		end
	end

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

	local pagename = args.pagename or mw.loadData("Module:headword/data").pagename

	local data = {
		lang = lang,
		pos_category = poscat,
		categories = {},
		heads = args.head,
		genders = {},
		inflections = {},
		pagename = pagename,
		id = args.id,
		sort_key = args.sort,
		force_cat_output = force_cat,
	}

	local is_suffix = false
	if pagename:find("^%-") and poscat ~= "suffix forms" then
		is_suffix = true
		data.pos_category = "suffixes"
		local singular_poscat = require("Module:string utilities").singularize(poscat)
		table.insert(data.categories, langname .. " " .. singular_poscat .. "-forming suffixes")
		table.insert(data.inflections, {label = singular_poscat .. "-forming suffix"})
	end

	if pos_functions[poscat] then
		pos_functions[poscat].func(def, args, data, is_suffix)
	end

    if args.json then
        return require("Module:JSON").toJSON(data)
    end
	
	return require("Module:headword").full_headword(data)
end

local function insert_inflection(data, list, label)
	if #list > 0 then
		list.label = label
		table.insert(data.inflections, list)
	end
end

pos_functions["verbs"] = {
	params = {
		["pres2s"] = {list = true},
		["pres3s"] = {list = true},
		["pres2p"] = {list = true},
		["impf"] = {list = true},
		["sperf"] = {list = true},
		["pp"] = {list = true},
		["impers"] = {type = "boolean"},
		["thirdonly"] = {type = "boolean"},
	},
	func = function(def, args, data, is_suffix)
		if args.impers then
			table.insert(data.inflections, {label = "impersonal"})
			data.gloss = "third-singular present indicative"
		elseif args.thirdonly then
			data.gloss = "third-singular present indicative"
		else
			data.gloss = "first-singular present indicative"
		end
		insert_inflection(data, args.pres2s, "second-person singular present indicative")
		insert_inflection(data, args.pres3s, "third-person singular present indicative")
		insert_inflection(data, args.pres2p, "second-person plural present indicative")
		insert_inflection(data, args.impf, "imperfect")
		insert_inflection(data, args.sperf, "simple perfect")
		insert_inflection(data, args.pp, "past participle")
	end,
}

return export