يمكن إنشاء صفحة توثيق الوحدة في وحدة:mnw-translit/شرح

local export = {}
local gsub = mw.ustring.gsub
local u = mw.ustring.char
local letter_with_mark = "(.["..u(0x0300).."-"..u(0x036F).."]?)"

local pre = {
	["ျ"] = "္ယ", ["ြ"] = "္ရ", ["ွ"] = "္ဝ", ["ှ"] = "္ဟ",
	["ၞ"] = "္န", ["ၟ"] = "္မ", ["ၠ"] = "္လ",
}

local tt1 = {
	-- consonants ; Unicode doesn't have exclusive great nya, that looks like ည with another curve, so use ည္ည as it should be.
	["က"] = "كَ", ["ခ"] = "كَ", ["ဂ"] = "غَ", ["ဃ"] = "غَ", ["င"] = "نَ", ["ၚ"] = "نَ",
	["စ"] = "تشَ", ["ဆ"] = "تشَ", ["ဇ"] = "جَ", ["ၛ"] = "جَ", ["ဉ"] = "نَ", ["ည"] = "نَ",  -- ن -> ن later
	["ဋ"] = "تَ", ["ဌ"] = "تَ", ["ဍ"] = "دَ", ["ဎ"] = "دَ", ["ဏ"] = "نَ",
	["တ"] = "تَ", ["ထ"] = "تَ", ["ဒ"] = "دَ", ["ဓ"] = "دَ", ["န"] = "نَ",
	["ပ"] = "بَ", ["ဖ"] = "بَ", ["ဗ"] = "بَ", ["ဘ"] = "بَ", ["မ"] = "مَ",
	["ယ"] = "يَ", ["ရ"] = "رَ", ["လ"] = "لَ", ["ဝ"] = "فَ", ["သ"] = "سَ", ["ဿ"] = "سَّ",
	["ဟ"] = "هَ", ["ဠ"] = "لَ", ["ၜ"] = "با", ["အ"] = "أَ", ["ၝ"] = "بي",
	-- independent vowels (1 char)
	["ဣ"] = "إِ", ["ဥ"] = "أُ",
	["ဨ"] = "إِي", ["ဩ"] = "أُو",
	-- dependent vowels and diacritics (1 char)
	["ါ"] = "َا", ["ာ"] = "َا", ["ိ"] = "إ", ["ီ"] = "إم", ["ဳ"] = "إ", ["ု"] = "أ", ["ူ"] = "أُو", ["ဲ"] = "ي",
	["ဴ"] = "أو", ["ေ"] = "إ", ["ဵ"] = "إ", 
	["ံ"] = "م", ["း"] = "ه", ["္"] = "¡", ["်"] = "ْ",
	-- punctuation marks
	["၊"] = "۔", ["။"] = "۔۔", 
	-- numerals
	["၀"] = "٠", ["၁"] = "١", ["၂"] = "٢", ["၃"] = "٣", ["၄"] = "٤",
	["၅"] = "٥", ["၆"] = "٦", ["၇"] = "٧", ["၈"] = "٨", ["၉"] = "٩",
	-- zero-width space (display it if it hides in a word)
	[u(0x200B)] = "‼", [u(0x200C)] = "‼", [u(0x200D)] = "‼",
}

local tt2 = {
	-- vowels (2 chars)
	["ဣဳ"] = "إِي", ["ဥု"] = "أُُ",
	["ေါ"] = "أ", ["ော"] = "أ",
}

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, ".", pre)
	text = gsub(text, "ဲါ", "ါဲ") -- fixed ay+aa to aa+ay; it often occurs

	for k, v in pairs(tt2) do
		text = gsub(text, k, v)
	end

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

	text = gsub(text, "([aeiuoāīū])ʸ", "%1y")
	text = gsub(text, "ᵃʸ", "oa")

	text = gsub(text, "ᵃ([¡¤]+)", "")
	text = gsub(text, "([aeiuoāīū])¤", "%1k")
	text = gsub(text, "ᵃ([aeiuoāīū])", "%1")
	text = gsub(text, "ᵃ", "a")

	text = gsub(text, "iṃu", "iuṃ")
	if lang == "mnw" then --Modern Mon
		text = gsub(text, "ññ", "ñ")
	end

	return text
 
end
 
return export