မဝ်ဂျူ:rup-headword

နူ ဝိက်ရှေန်နရဳ
ထာမ်ပလိက်တဏအ်ဒးနွံကဵုလိက်စၟတ်သမ္တီမချူလဝ်သာဓက။
သ္ပဂုန်တုဲထာမ်ပလိက်တဏအ်ဒးစၟတ်သမ္တီကဵုလိက်မချူလဝ်နူကဵုဓမံက်ထ္ၜးကဵုဗီုပြၚ်ကိစ္စမရန်တၟအ်လဝ် ကဵု ပရေၚ်မရပ်စပ်လ္တူမုက်လိက်နကဵုလိက်စၟတ်သမ္တီမချူလဝ်သာဓက

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 = "အာရဝ်မေနဳယာန်"

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.title.getCurrentTitle().text

	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 ~= "ဗီုပြင်အဆက်လက္ကရဴ" then
		is_suffix = true
		data.pos_category = "အဆက်လက္ကရဴ"
		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["ကြိယာ"] = {
	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 = "ဟွဲမွဲကဵုပစ္စဲပူဂဵု"})
			data.gloss = "ကိုန်ဨကဝုစ်မပညုၚ်ထ္ၜးပစ္စုပ္ပန်နကဵုတတိယ"
		elseif args.thirdonly then
			data.gloss = "ကိုန်ဨကဝုစ်မပညုၚ်ထ္ၜးပစ္စုပ္ပန်နကဵုတတိယ"
		else
			data.gloss = "ကိုန်ဨကဝုစ်မပညုၚ်ထ္ၜးပစ္စုပ္ပန်နကဵုပထမ"
		end
		insert_inflection(data, args.pres2s, "ကိုန်ဨကဝုစ်မပညုၚ်ထ္ၜးပစ္စုပ္ပန်နကဵုပူဂဵုဒုတိယ")
		insert_inflection(data, args.pres3s, "ကိုန်ဨကဝုစ်မပညုၚ်ထ္ၜးပစ္စုပ္ပန်နကဵုပူဂဵုတတိယ")
		insert_inflection(data, args.pres2p, "ကိုန်ဗဟုဝစ်မပညုၚ်ထ္ၜးပစ္စုပ္ပန်နကဵုပူဂဵုဒုတိယ")
		insert_inflection(data, args.impf, "မဟၟဲဍိုက်ပေၚ်")
		insert_inflection(data, args.sperf, "ဗီုပြၚ်ဓမ္မတာနကဵုမခိုဟ်တဴဗွဲတၟေၚ်")
		insert_inflection(data, args.pp, "ဗီုပြၚ်ကြိယာနကဵုအတိတ်")
	end,
}

return export