Module:aio-headword

From Wiktionary, the free dictionary
Jump to navigation Jump to search


-- The following code is same as phk, kht. Just different at language code.

local export = {}
local pos_functions = {}

local gsub = mw.ustring.gsub
local u = mw.ustring.char

local lang = require("Module:languages").getByCode("aio")
local script = require("Module:scripts").getByCode("Mymr")
local PAGENAME = mw.title.getCurrentTitle().text

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 headword = args["head"] or PAGENAME
	if mw.ustring.find(headword, u(0xFE00), 1, true) then
		error("Please remove the variant selector character [VS1] from headword.")
	end
	local head = dotted_form(headword) -- for displaying only
	local tr = args["tr"]

	local data = {lang = lang, sc = script, pos_category = poscat, categories = {}, heads = {head}, translits = {tr}, inflections = {}}

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

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

end

-- https://www.unicode.org/Public/UNIDATA/StandardizedVariants.txt
function dotted_form(text)

	return gsub(text, "([ကဂငတထပမယလဝဢေၵၸၺႀꩠꩡꩢꩣꩤꩥꩦꩫꩬꩯꩺ])", "%1" .. u(0xFE00))

end

--pos_functions here

return export