မဝ်ဂျူ:root

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

local export = {}

local m_languages = require("Module:languages")

function export.categorize(lang, source, roots, ids, sort_key)
	local categories = {}
	
	if lang:getCode() ~= source:getCode() then
		table.insert(categories, "ဝေါဟာ" ..
			lang:getCanonicalName() .. "ကၠုင်နူဝေါဟာ" .. source:getCanonicalName() .. "ဂမၠိုင်")
	end
	
	for index, root in ipairs(roots) do
		if lang:getCode() == source:getCode() then
			table.insert(categories, "ဝေါဟာ" ..
				lang:getCanonicalName() .. "ပိုင်ပြဳလဝ်မအရေဝ်တံမူလနကဵုဝေါဟာ" .. root .. (ids[index] and " (" .. ids[index] .. ")" or ""))
		else
			table.insert(categories, "ဝေါဟာ" ..
				lang:getCanonicalName() .. "မဆက်ဆေန်စှ်ေကၠုင်နူတံရိုဟ်" .. source:getCanonicalName() ..
						"နကဵုအဆက်ဝေါဟာ " .. root .. (ids[index] and " (" .. ids[index] .. ")" or ""))
		end
	end
	
	return require("Module:utilities").format_categories(categories, lang, sort_key)
end

function export.show(frame)
	local params = {
		[1] = { required = true },
		[2] = { required = true },
		[3] = { required = true, list = true },
		["id"] = { list = true, allow_holes = true },
		["sort"] = {},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local lang = m_languages.getByCode(args[1]) or m_languages.error(args[1], 1)
	local source = m_languages.getByCode(args[2]) or m_languages.error(args[2], 2)
	
	return export.categorize(lang, source, args[3], args.id, args.sort)
end

return export