Module:Wp/mnc/Mnc-translit

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

local export = {}

local conv = {
	["ᠠ"] = "a",
	["ᡝ"] = "e",
	["ᡳ"] = "i",
	["ᠣ"] = "o",
	["ᡠ"] = "u",
	["ᡡ"] = "ū",
	["ᠨ"] = "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",
	["ᡯᡳ"] = "dzi",
	["᠎"] = "-",
	["᠈"] = ",",
	["᠉"] = ".",
	[" "] = "-",
	["᠊"] = "-"
}

function export.tr(text, lang, sc)
	if sc ~= "Mong" then
		return nil
	end
	
	text = mw.ustring.gsub(text, "([ᠠᡝᡳᡟᠣᡠᡡᠨᠩᡴᡤᡥᠪᡦᠰᡧᡨᡩᠯᠮᠴᠵᠶᡵᡶᠸᠺᡬᡭᡮᡯᡰᡱᡷ᠈᠉])([ᡟᡳ]?)", function(a, b)
		return conv[a..b] or conv[a] .. conv[b] end)
	return text
end

return export