မဝ်ဂျူ:Tavt-translit

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

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

local export = {}
local gsub = mw.ustring.gsub

local tt = {
	-- consonants
	["ꪀ"] = "k", ["ꪁ"] = "ḵ", ["ꪂ"] = "k̄h", ["ꪃ"] = "kh", ["ꪄ"] = "ḳ̄h", ["ꪅ"] = "kʹh", ["ꪆ"] = "?", ["ꪇ"] = "?", ["ꪈ"] = "h̄ng", ["ꪉ"] = "ng",
	["ꪊ"] = "c", ["ꪋ"] = "c̱", ["ꪌ"] = "c̄h", ["ꪍ"] = "ch", ["ꪎ"] = "s̄", ["ꪏ"] = "s", ["ꪐ"] = "h̄ỵ", ["ꪑ"] = "ỵ",
	["ꪒ"] = "d", ["ꪓ"] = "ḏ", ["ꪔ"] = "t", ["ꪕ"] = "ṯ", ["ꪖ"] = "t̄h", ["ꪗ"] = "th", ["ꪘ"] = "h̄n", ["ꪙ"] = "n",
	["ꪚ"] = "b", ["ꪛ"] = "ḇ", ["ꪜ"] = "p", ["ꪝ"] = "p̱", ["ꪞ"] = "p̄h", ["ꪟ"] = "ph", ["ꪠ"] = "f̄", ["ꪡ"] = "f", ["ꪢ"] = "h̄m", ["ꪣ"] = "m",
	["ꪤ"] = "h̄y", ["ꪥ"] = "y", ["ꪦ"] = "h̄r", ["ꪧ"] = "r", ["ꪨ"] = "h̄l", ["ꪩ"] = "l", ["ꪪ"] = "h̄w", ["ꪫ"] = "w",
	["ꪬ"] = "h̄", ["ꪭ"] = "ḥ", ["ꪮ"] = "x", ["ꪯ"] = "x̱",
	-- vowels and finals (visual ordering)
	["ꪰ"] = "'", ["ꪱ"] = "ā", ["ꪲ"] = "l", ["ꪳ"] = "ụ", ["ꪴ"] = "ุ", ["ꪵ"] = "æ", ["ꪶ"] = "o",
	["ꪷ"] = "'", ["ꪸ"] = "y", ["ꪹ"] = "e", ["ꪺ"] = "ัw", ["ꪻ"] = "i", ["ꪼ"] = "ị",
	["ꪽ"] = "ัn", ["ꪾ"] = "ả",
	-- tones
	["꪿"] = "'", ["ꫀ"] = "<sup>1</sup>", ["꫁"] = "'", ["ꫂ"] = "<sup>2</sup>",
	-- symbols
	["ꫛ"] = "ko̱n", ["ꫜ"] = "nụ̀ng", ["ꫝ"] = "«", ["꫞"] = "§", ["꫟"] = "»",
}

function export.tr(text, lang, sc, debug_mode)

	if type(text) == "table" then -- called directly from a template
		text = text.args[1]
	end

	text = gsub(text, ".", tt)

	text = gsub(text, "([่้๋̱])([ัิีึืุู])", "%2%1")
	text = gsub(text, "([^%s%p%z])bả", "%1ัb")
	text = gsub(text, "(ả)([่้๋̱])", "%2%1")

	return text

end

return export