မာတိကာသို့ ခုန်သွားရန်

မဝ်ဂျူ:ny

နူ ဝိက်ရှေန်နရဳ

Documentation for this module may be created at မဝ်ဂျူ:ny/doc

local export = {}
local gsub = mw.ustring.gsub

function export.new(frame)
	local title = mw.title.getCurrentTitle().text
	local args = frame:getParent().args
	local pos = args[1] or ""
	local def = args[2] or "{{rfdef|ny}}"
	local pos2 = args[3] or (args[4] and "" or false)
	local def2 = args[4] or "{{rfdef|ny}}"
	local pos3 = args[5] or (args[6] and "" or false)
	local def3 = args[6] or "{{rfdef|ny}}"
	local etym = args["e"] or false
	local head = args["h"] or false
	local cat = args["cat"] or false
	local usage = args["un"] or false
	local class = args["c"] or false
	local plural = args["pl"] or false
	local class2 = args["c2"] or false
	local plural2 = args["pl2"] or false
	local class3 = args["c3"] or false
	local plural3 = args["pl3"] or false
	
	local result = ""
	
	local function genTitle(text)
		local pos_title = {
			[""] = "နာမ်", ["n"] = "နာမ်", ["pn"] = "နာမ်မကိတ်ညဳ", ["propn"] = "နာမ်မကိတ်ညဳ", ["pron"] = "သဗ္ဗနာမ်",
			["v"] = "ကြိယာ", ["vf"] = "ကြိယာ", ["a"] = "နာမဝိသေသန", ["adj"] = "နာမဝိသေသန", ["adv"] = "ကြိယာဝိသေသန",
			["prep"] = "ဝိဘတ်", ["postp"] = "ဝိဘတ်", ["conj"] = "Conjunction",
			["part"] = "Particle", ["suf"] = "Suffix",
			["prov"] = "Proverb", ["id"] = "Idiom", ["ph"] = "Phrase", ["intj"] = "Interjection", ["interj"] = "Interjection",
		    ["num"] = "Numeral", ["abb"] = "Abbreviation", ["deter"] = "Determiner"
		};
		return pos_title[text] or mw.ustring.upper(mw.ustring.sub(text, 1, 1)) .. mw.ustring.sub(text, 2, -1)
	end
	
	local function genHead(text)
		local pos_head = {
			[""] = "noun", ["n"] = "noun", ["pn"] = "proper noun", ["propn"] = "proper noun", ["v"] = "verb", ["vf"] = "verb form", ["a"] = "adj",
			["prep"] = "preposition", ["conj"] = "con", ["part"] = "particle", ["pron"] = "pronoun",
			["prov"] = "proverb", ["id"] = "idiom", ["ph"] = "phrase", ["intj"] = "interj",
			["abb"] = "abbr", ["deter"] = "det"
		};
		return pos_head[text] or text
	end
	
	local function other(class, title, args)
		local code = ""
		if args[class] then
			if (mw.ustring.gmatch(args[class], "^-")) then
				code = code .. "\n\n===" .. title .. "===\n* {{l|ny|" .. mw.ustring.gsub(args[class], "^-", "") .. "|" .. args[class] .. "}}"
			else
				code = code .. "\n\n===" .. title .. "===\n* {{l|ny|" .. args[class] .. "}}"
			end
		end
		for i=1,6 do
			if args[class .. i] then
				if (mw.ustring.gmatch(args[class..i], "^-")) then
					code = code .. "\n* {{l|ny|" .. mw.ustring.gsub(args[class..i], "^-", "") .. "|" .. args[class..i] .. "}}"
				else
					code = code .. "\n* {{l|ny|" .. args[class..i] .. "}}"
				end
			end
		end
		return code
	end
	
	result = result .. "==Chichewa=="
	if args["wp"] then result = result .. "\n{{wikipedia|lang=ny" .. 
		(args["wp"] == "y" and "" or "|" .. args["wp"]) .. "}}" end
	result = result .. other("alt", "Alternative forms", args)
	
	if etym then result = result .. "\n\n===Etymology===\n" .. etym end
	
	result = result .. "\n\n===Pronunciation===\n* {{ny-IPA" .. (head and ("|" .. require("Module:links").remove_links(head)) or "") .. "}}"
	
	result = result .. "\n\n===" .. genTitle(pos) .. "===\n{{ny-" .. genHead(pos) .. (head and ("|" .. gsub(head,"([bdmn])'","%1")) or "") .. (class and ("|" .. class) or "") .. (plural and ("|" .. plural) or "") .. "}}\n\n# " .. def
	
	result = result .. other("syn", "=Synonyms=", args)
	result = result .. other("ant", "=Antonyms=", args)
	result = result .. other("rel", "=Related terms=", args)
	result = result .. other("der", "=Derived terms=", args)
	if vder then result = result .. "\n\n====Derived terms====\n" .. vder end
	result = result .. other("also", "=See also=", args)
	
	if usage then result = result .. "\n\n====Usage notes====\n" .. usage end
	
	if pos2 then
		result = result .. "\n\n===" .. genTitle(pos2) .. "===\n{{ny-" .. genHead(pos2) .. (head and ("|head=" .. gsub(head,"([bdmn])'","%1")) or "") .. (class2 and ("|" .. class2) or "") .. (plural2 and ("|" .. plural2) or "") .. "}}\n\n# " .. def2
	end
	
	if pos3 then
		result = result .. "\n\n===" .. genTitle(pos3) .. "===\n{{ny-" .. genHead(pos3) .. (head and ("|head=" .. gsub(head,"([bdmn])'","%1")) or "") .. (class3 and ("|" .. class3) or "") .. (plural3 and ("|" .. plural3) or "") .. "}}\n\n# " .. def3
	end
	
	if cat then result = result .. "\n\n{{C|ny|" .. cat .. "}}" end
	
	return result
end

function export.acute_on_first_vowel(frame)
	local word = frame.args[1]
	if not word then
		return ""
	end
	-- Decompose word, find first vowel, add acute to it if it doesn't have one,
	-- remove second return value.
	-- Recomposing unnecessary.
	local acute = mw.ustring.char(0x0301)
	return (mw.ustring.gsub(
		mw.ustring.toNFD(word),
		"([AaEeIiOoUu])" .. acute .. "?",
		"%1" .. acute,
		1))
end

return export
ကလေၚ်သီကေတ်လဝ် နူ "https://mnw.wiktionary.org/w/index.php?title=မဝ်ဂျူ:ny&oldid=51969"