local export = {}
local gsub = mw.ustring.gsub
local u = mw.ustring.char
local tt = {
-- consonants
['𐨐'] = 'ก', ['𐨑'] = 'ข', ['𐨒'] = 'ค', ['𐨓'] = 'ฆ',
['𐨕'] = 'จ', ['𐨖'] = 'ฉ', ['𐨗'] = 'ช', ['𐨙'] = 'ญ',
['𐨚'] = 'ฏ', ['𐨛'] = 'ฐ', ['𐨜'] = 'ฑ', ['𐨝'] = 'ฒ', ['𐨞'] = 'ณ',
['𐨟'] = 'ต', ['𐨠'] = 'ถ', ['𐨡'] = 'ท', ['𐨢'] = 'ธ', ['𐨣'] = 'น',
['𐨤'] = 'ป', ['𐨥'] = 'ผ', ['𐨦'] = 'พ', ['𐨧'] = 'ภ', ['𐨨'] = 'ม',
['𐨩'] = 'ย', ['𐨪'] = 'ร', ['𐨫'] = 'ล', ['𐨬'] = 'ว',
['𐨭'] = 'ศ', ['𐨮'] = 'ษ', ['𐨯'] = 'ส', ['𐨰'] = 'ซ', ['𐨱'] = 'ห',
['𐨲'] = 'ก̱', ['𐨳'] = 'ฐ̱', ['𐨀'] = 'อ',
-- diacritics
['𐨍'] = '͚', ['𐨎'] = 'ํ', ['𐨏'] = 'ห์',
['𐨸'] = '̄', ['𐨹'] = '̱', ['𐨺'] = '̣', ['𐨿'] = 'ฺ',
-- numbers
['𐩀'] = '[1]', ['𐩁'] = '[2]', ['𐩂'] = '[3]', ['𐩃'] = '[4]',
['𐩄'] = '[10]', ['𐩅'] = '[20]', ['𐩆'] = '[100]', ['𐩇'] = '[1000]',
-- marks
['𐩖'] = 'ฯ', ['𐩗'] = '๚', ['𐩓'] = '๛', ['𐩔'] = '๏',
-- zero-width space (display it if it hides in a word)
[u(0x200B)] = '‼',
}
local adjust1 = {
-- single & composite vowels
[''] = '', ['𐨌'] = 'า',
['𐨁'] = 'ิ', ['𐨁𐨌'] = 'ี', ['𐨂'] = 'ุ', ['𐨂𐨌'] = 'ู',
['𐨃'] = 'ฺฤ', ['𐨃𐨌'] = 'ฺฤๅ',
['𐨅'] = '↶เ', ['𐨅𐨌'] = '↶ไ', ['𐨆'] = '↶โ', ['𐨆𐨌'] = '↶เา',
}
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, '[𐨁𐨂𐨃𐨅𐨆]?𐨌?', adjust1)
text = gsub(text, '.', tt)
text = gsub(text, '([ก-ฮ]̱?)↶([เแไโ])', '%2%1')
-- ย้ายสัญลักษณ์ขึ้นบน เมื่อมีสระล่าง (ยกเว้นตัวที่ไม่มี)
text = gsub(text, u(0x0331)..'([ุ-ฺ])', u(0x0304)..'%1') -- macron below > macron above
return text
end
return export