Module:Wp/mnc/Mnc-Latn-translit

From Wikimedia Incubator

Documentation for this module may be created at Module:Wp/mnc/Mnc-Latn-translit/doc

local export = {}

local vowel = {
	["a"] = "ᠠ",
	["e"] = "ᡝ",
	["i"] = "ᡳ",
	["y"] = "ᠶ",
	["o"] = "ᠣ",
	["u"] = "ᡠ",
	["ū"] = "ᡡ",
}

local consonant = {
	["n"] = "ᠨ",
	["ng"] = "ᠩ",
	["k"] = "ᡴ",
	["g"] = "ᡤ",
	["h"] = "ᡥ",
	["b"] = "ᠪ",
	["p"] = "ᡦ",
	["s"] = "ᠰ",
	["š"] = "ᡧ",
	["t"] = "ᡨ",
	["d"] = "ᡩ",
	["l"] = "ᠯ",
	["m"] = "ᠮ",
	["c"] = "ᠴ",
	["j"] = "ᠵ",
	["y"] = "ᡟ",
	["r"] = "ᡵ",
	["f"] = "ᡶ",
	["w"] = "ᠸ",
	["k'"] = "ᠺ",
	["g'"] = "ᡬ",
	["h'"] = "ᡭ",
	["ts'"] = "ᡮ",
	["ts"] = "ᡮᡟ",
	["dz"] = "ᡯ",
	["ž"] = "ᡰ",
	["sy"] = "ᠰᡟ",
	["c'"] = "ᡱ",
	["c'y"] = "ᡱᡳ",
	["jy"] = "ᡷᡳ",
	[","] = "᠈",
	["."] = "᠉",
	["v"] = "ᡡ",
	["q"] = "ᠴ᠋",
	["x"] = "ᡧ᠋",
	["z"] = "ᡯ᠋",
}

function export.tr(text)
	if type(text) == "table" then
		text = text:getParent().args[1]
	end
	text = mw.ustring.gsub(text, "W[a-z]/[a-z][a-z][a-z]?/", "")
	text = mw.ustring.gsub(text, "ng", consonant)
	text = mw.ustring.gsub(text, "ts", consonant)
	text = mw.ustring.gsub(text, "dz", consonant)
	text = mw.ustring.gsub(text, "[^aeiouūy]'?y?", consonant)
	text = mw.ustring.gsub(text, ".", vowel)
	return text
end

return export