Modul:pa-headword

A Wikiszótárból, a nyitott szótárból

A modult a Modul:pa-headword/doc lapon tudod dokumentálni

local export = {}
local pos_functions = {}

local lang = require("Module:languages").getByCode("pa")
local PAGENAME = mw.title.getCurrentTitle().text
local script = require("Module:scripts").findBestScript(PAGENAME, lang) -- Guru or pa-Arab

function export.show(frame)

	local args = frame:getParent().args
	local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")

	local data = {lang = lang, sc = script, pos_category = poscat, categories = {"Punjabi " .. poscat .. " in " .. script:getCategoryName()}, heads = {args["head"] or PAGENAME}, genders = {}, inflections = {}}

	local mas = {label = "masculine counterpart"}
	if args["m"] then table.insert(mas, args["m"]) end
	if args["m2"] then table.insert(mas, args["m2"]) end
	if args["m3"] then table.insert(mas, args["m3"]) end
	if #mas > 0 then table.insert(data.inflections, mas) end

	local fem = {label = "feminine counterpart"}
	if args["f"] then table.insert(fem, args["f"]) end
	if args["f2"] then table.insert(fem, args["f2"]) end
	if args["f3"] then table.insert(fem, args["f3"]) end
	if #fem > 0 then table.insert(data.inflections, fem) end

	local gur = {label = "Gurmukhi spelling", lang = lang, sc = require("Module:scripts").getByCode("Guru")}
	if args["gur"] then table.insert(gur, args["gur"]) end
	if args["gur2"] then table.insert(gur, args["gur2"]) end
	if args["gur3"] then table.insert(gur, args["gur3"]) end
	if #gur > 0 then table.insert(data.inflections, gur) end

	local sha = {label = "Shahmukhi spelling", lang = lang, sc = require("Module:scripts").getByCode("pa-Arab")}
	if args["sha"] then table.insert(sha, args["sha"]) end
	if args["sha2"] then table.insert(sha, args["sha2"]) end
	if args["sha3"] then table.insert(sha, args["sha3"]) end
	if #sha > 0 then table.insert(data.inflections, sha) end

	if pos_functions[poscat] then
		pos_functions[poscat](args, data)
	end

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

end

pos_functions["nouns"] = function(args, data)

	local pls = {label = "plural"}
	if args["pl"] then table.insert(pls, args["pl"]) end
	if args["pl2"] then table.insert(pls, args["pl2"]) end
	if args["pl3"] then table.insert(pls, args["pl3"]) end
	if #pls > 0 then table.insert(data.inflections, pls) end

	table.insert(data.genders, args["g"] or "?")

end

pos_functions["proper nouns"] = function(args, data)

	table.insert(data.genders, args["g"] or "?")

end

return export