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

မဝ်ဂျူ:mul-letter

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

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

local export = {}
local PAGENAME = mw.title.getCurrentTitle().text

local function getCasing(char, variant)
	if not variant then
		variant = "common"
	end
	local casing = require("Module:mul-letter/data")[variant][char]
	if not casing then
		if mw.ustring.len(char) > 1 then
			casing = {mw.ustring.lower(char), mw.ustring.upper(mw.ustring.sub(char, 1, 1)) .. mw.ustring.lower(mw.ustring.sub(char, 2, -1)), mw.ustring.upper(char)}
		else
			casing = {mw.ustring.lower(char), mw.ustring.upper(char), mw.ustring.upper(char)}
		end
	end
	return casing
end

function export.show(frame)
	local args = frame:getParent().args
	local head = args["head"] or PAGENAME
	local lang = require("Module:languages").getByCode("mul")
	local scriptCode = args["sc"] or args["script"] or require("Module:scripts").findBestScriptWithoutLang(head):getCode()
	local script = scriptCode and require("Module:scripts").getByCode(scriptCode) or lang:findBestScript(head)
	local variant = args["var"]
	
	if args.script then
		require("Module:debug").track("mul-letter/script-param")
	end

	local data = {
		lang = lang,
		sc = script,
		pos_category = "အက္ခရ်",
		categories = {},
		heads = {head},
		no_redundant_head_cat = not args.head,
		inflections = {}
	}

	local casing = getCasing(head, variant)
	if casing[1] ~= head then
		table.insert(data.inflections, {label = "အက္ခရ်မဍောတ်", casing[1]})
	end
	if casing[2] ~= head and casing[2] ~= casing[3] then
		table.insert(data.inflections, {label = "အက္ခရ်ပံၚ်ကောံ", casing[2]})
	end
	if casing[3] ~= head then
		table.insert(data.inflections, {label = "အက္ခရ်မဇၞော်", casing[3]})
	end

	return require("Module:headword").full_headword(data)
		.. require("Module:utilities").format_categories({"ဗျဉ်" .. 
			script:getCategoryName() .. "ဂမၠိုင်",
		}, lang)
end

return export