Module:urk-translit

local export = {}

local urk = require("Module:urk-common") local match = mw.ustring.match

local initials = { ["ก"] = "k", ["กฺ"] = "g", ["ค"] = "kh", ["ง"] = "ng", ["จ"] = "c", ["ช"] = "ch", ["ซ"] = "s", ["ฌ"] = "ch", -- nonstandard spellling ["ญ"] = "ny", ["ด"] = "d", ["ต"] = "t", ["ท"] = "th", ["น"] = "n", ["บ"] = "b", ["ป"] = "p", ["พ"] = "ph", ["ฟ"] = "f", ["ม"] = "m", ["ย"] = "y", ["ยฺ"] = "j", ["ร"] = "r", ["ล"] = "l", ["ว"] = "w", ["อ"] = "ʼ", ["ฮ"] = "h" }

local medials = { ["ร"] = "r", ["ล"] = "l" }

local vowels = { ["อ"] = "ö", ["เ"] = "ë", ["เว"] = "aw", ["เอ"] = "e", ["เิ"] = "e", ["เีย"] = "ia", ["แ"] = "ä", ["โ"] = "o", ["ั"] = "a", ["ัว"] = "ua", ["า"] = "a", ["ิ"] = "i", ["ี"] = "i", ["ึ"] = "e", -- nonstandard spelling ["ื"] = "e", ["ุ"] = "u", ["ู"] = "u" }

local finals = { ["ก"] = "k", ["ง"] = "ng", ["จ"] = "c", -- alterative spelling ["ด"] = "t", ["น"] = "n", ["บ"] = "p", ["ม"] = "m", ["ย"] = "y", ["ยจ"] = "c", ["ยฮ"] = "s", ["ยํ"] = "l", -- variable pronunciation ["ล"] = "l", -- only in phuket ["ว"] = "w", ["ฮ"] = "h", ["ะ"] = "q", ["ะฮ"] = "h" -- alterative spelling }

-- main function function export.tr(text, lang, sc) local translit = "" local respelt = urk.syllabise(text, true)

for _, segment in ipairs(respelt) do		if match(segment, "[ก-๎]") then local v_pref, i, m, v_suf, f_pref, f_suf = match(segment, urk.syllable_pattern)

local v = v_pref .. v_suf -- special case for "เีย" if v_pref == "เ" and v_suf == "ี" and f_pref == "ย" then v = "เีย" f_pref = "" end local f = f_pref .. f_suf

-- join components together translit = translit .. (initials[i] or "") .. (medials[m] or "") .. (vowels[v] or "") .. (finals[f] or "") else translit = translit .. segment end end

return translit end

return export