မာတိကာသို့ ခုန်သွားရန်

မဝ်ဂျူ:th-translit/2

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

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

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
	["ก"] = "က", ["ข"] = "ခ", ["ค"] = "ဂ", ["ฆ"] = "ဃ", ["ง"] = "ၚ", 
	["จ"] = "စ", ["ฉ"] = "ဆ", ["ช"] = "ဇ", ["ฌ"] = "ၛ", ["ญ"] = "ဉ", ["ญ"] = "ည",
	["ฏ"] = "ဋ", ["ฐ"] = "ဌ", ["ฑ"] = "ဍ", ["ฒ"] = "ဎ", ["ณ"] = "ဏ",
	["ต"] = "တ", ["ถ"] = "ထ", ["ท"] = "ဒ", ["ธ"] = "ဓ", ["น"] = "န",
	["ป"] = "ပ", ["ผ"] = "ဖ", ["พ"] = "ဗ", ["ภ"] = "ဘ", ["ม"] = "မ",
	["ย"] = "ယ", ["ร"] = "ရ", ["ล"] = "လ", ["ว"] = "ဝ", ["ส"] = "သ", ["สฺส"] = "ဿ",
	["ห"] = "ဟ", ["ฬ"] = "ဠ", ["บ"] = "ၜ", ["อ"] = "အ", ["บ"] = "ၝ",
	-- independent vowels (1)
	["อิ"] = "ဣ", ["อุ"] = "ဥ",
	["เอ"] = "ဨ", ["โอ"] = "ဩ",
	-- dependent vowels and diacritics (excluding front type)
	["า"] = "ါ", ["า"] = "ာ", ["ิ"] = "ိ", ["ิํ"] = "ီ", ["ี"] = "ဳ", [""] = "ု", [""] = "ူ", ["ัว"] = "ဲ", 
	["ํ"] = "ံ", ["ห์"] = "း", [""] = "္", [""] = "်",
	-- 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)
	["อี"] = "ဣဳ", ["อู"] = "ဥု",
	["เ%1า"] = "ဴ", ["เ%1"] = "ေ",
	["โ%1"] = "ေါ", ["โ%1"] = "ော",
	["%1าย"] = "ါဲ", ["%1าย"] = "ာဲ",
	["%1ุย"] = "ုဲ", ["เ%1อ̂"] = "ဵု",
}

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)

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

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

	return text
 
end
 
return export