มอดูล:ru-translit-Thai
หน้าตา
- This มอดูล lacks a documentation subpage. Please create it.
- Useful links: subpage list • links • transclusions • testcases • sandbox
local export = {}
local gsub = mw.ustring.gsub
local u = mw.ustring.char
local tab = {
["а"]="ั", ["б"]="บ", ["в"]="วฺ", ["г"]="กฺ", ["д"]="ด",
["е"]="เย", ["ё"]="โย", ["ж"]="ชฺ", ["з"]="ซฺ", ["и"]="ิ", ["й"]="ย",
["к"]="ก", ["л"]="ล", ["м"]="ม", ["н"]="น", ["о"]="↶โ",
["п"]="ป", ["р"]="ร", ["с"]="ซ", ["т"]="ต", ["у"]="ุ", ["ф"]="ฟ",
["х"]="ฅ", ["ц"]="ต͜ซ", ["ч"]="ช", ["ш"]="ฌ", ["щ"]="ฌฺ",
["ъ"]=u(0x02BA), ["ы"]="ึ", ["ь"]=u(0x02B9), ["э"]="↶เ", ["ю"]="ยุ", ["я"]="ยั",
-- Russian style quotes
["«"]="“", ["»"]="”",
-- archaic, pre-1918 letters
["і"]="ิ", ["ѳ"]="ฟ",
["ѣ"]="เย", ["ѵ"]="ิ",
}
local tab2 = {
-- digraphs
["дж"]="จฺ", ["дз"]="ด͜ซฺ", ["кх"]="ค", ["нг"]="ง", ["пх"]="พ", ["тх"]="ท",
-- diphthongs
["аа"]="า", ["а[еѣ]"]="าเย", ["аё"]="าโย", ["а[иіѵ]"]="าอิ", ["ао"]="าโอ",
["ау"]="าอุ", ["аы"]="าอึ", ["аэ"]="าเอ", ["аю"]="ายุ", ["ая"]="ายั",
["[еѣ]а"]="เยอั", ["[еѣ][еѣ]"]="เย", ["[еѣ]ё"]="เยโย", ["[еѣ][иіѵ]"]="เยอิ", ["[еѣ]о"]="เยโอ",
["[еѣ]у"]="เยอุ", ["[еѣ]ы"]="เยอึ", ["[еѣ]э"]="เย", ["[еѣ]ю"]="เยยุ", ["[еѣ]я"]="เยยั",
["ёа"]="โยอั", ["ё[еѣ]"]="โยเย", ["ёё"]="โย", ["ё[иіѵ]"]="โยอิ", ["ёо"]="โย",
["ёу"]="โยอุ", ["ёы"]="โยอึ", ["ёэ"]="โยเอ", ["ёю"]="โยยุ", ["ёя"]="โยยั",
["[иіѵ]а"]="ีอั", ["[иіѵ][еѣ]"]="ีเย", ["[иіѵ]ё"]="ีโย", ["[иіѵ][иіѵ]"]="ี", ["[иіѵ]о"]="ีโอ",
["[иіѵ]у"]="ีอุ", ["[иіѵ]ы"]="ีอึ", ["[иіѵ]э"]="ีเอ", ["[иіѵ]ю"]="ียุ", ["[иіѵ]я"]="ียั",
["оа"]="↶โอั", ["о[еѣ]"]="↶โเย", ["оё"]="↶โโย", ["о[иіѵ]"]="↶โอิ", ["оо"]="↶โ",
["оу"]="↶โอุ", ["оы"]="↶โอึ", ["оэ"]="↶โเอ", ["ою"]="↶โยุ", ["оя"]="↶โยั",
["уа"]="ูอั", ["у[еѣ]"]="ูเย", ["уё"]="ูโย", ["у[иіѵ]"]="ูอิ", ["уо"]="ูโอ",
["уу"]="ู", ["уы"]="ูอึ", ["уэ"]="ูเอ", ["ую"]="ูยุ", ["уя"]="ูยั",
["ыа"]="ือั", ["ы[еѣ]"]="ืเย", ["ыё"]="ืโย", ["ы[иіѵ]"]="ือิ", ["ыо"]="ืโอ",
["ыу"]="ือุ", ["ыы"]="ื", ["ыэ"]="ืเอ", ["ыю"]="ูยุ", ["ыя"]="ูยั",
["эа"]="↶เอั", ["э[еѣ]"]="↶เเย", ["эё"]="↶เโย", ["э[иіѵ]"]="↶เอิ", ["эо"]="↶เโอ",
["эу"]="↶เอุ", ["эы"]="↶เอึ", ["ээ"]="↶เ", ["эю"]="↶เยุ", ["эя"]="↶เยั",
["юа"]="ยูอั", ["ю[еѣ]"]="ยูเย", ["юё"]="ยูโย", ["ю[иіѵ]"]="ยูอิ", ["юо"]="ยูโอ",
["юу"]="ยู", ["юы"]="ยูอึ", ["юэ"]="ยูเอ", ["юю"]="ยู", ["юя"]="ยูยั",
["яа"]="ยา", ["я[еѣ]"]="ยาเย", ["яё"]="ยาโย", ["я[иіѵ]"]="ยาอิ", ["яо"]="ยาโอ",
["яу"]="ยาอุ", ["яы"]="ยาอึ", ["яэ"]="ยาเอ", ["яю"]="ยายุ", ["яя"]="ยา",
}
function export.tr(text, lang, sc, debug_mode)
if type(text) == "table" then -- called directly from a template
text = text.args[1]
end
text = mw.ustring.lower(text)
--text = mw.ustring.toNFD(text) -- breaks acute composition
text = gsub(text, "["..u(0x02CA)..u(0x0301)..u(0x0341).."]", "") -- removes acutes
for k, v in pairs(tab2) do
text = gsub(text, k, v)
end
text = gsub(text, ".", tab)
-- adds อ at the begining
text = gsub(text, "^([ัาิีึืุู↶])", "อ%1")
text = gsub(text, "([%s%p])([ัาิีึืุู↶])", "%1อ%2")
text = gsub(text, "([ก-ฮ]ฺ?)↶([เโ])", "%2%1")
-- extends vowels
text = gsub(text, "ั$", "า")
text = gsub(text, "ั([%s%p])", "า%1")
text = gsub(text, "ิ$", "ี")
text = gsub(text, "ิ([%s%p])", "ี%1")
text = gsub(text, "ุ$", "ู")
text = gsub(text, "ุ([%s%p])", "ู%1")
text = gsub(text, "ึ$", "ื")
text = gsub(text, "ึ([%s%p])", "ื%1")
text = gsub(text, "ั([ก-ฮ]ฺ?)([ัาิีึืุู])", "า%1%2")
text = gsub(text, "ิ([ก-ฮ]ฺ?)([ัาิีึืุู])", "ี%1%2")
text = gsub(text, "ึ([ก-ฮ]ฺ?)([ัาิีึืุู])", "ื%1%2")
text = gsub(text, "ุ([ก-ฮ]ฺ?)([ัาิีึืุู])", "ู%1%2")
text = gsub(text, "ั([ก-ฮ]ฺ?)([ัาิีึืุู])", "า%1%2") --twice
text = gsub(text, "ิ([ก-ฮ]ฺ?)([ัาิีึืุู])", "ี%1%2")
text = gsub(text, "ึ([ก-ฮ]ฺ?)([ัาิีึืุู])", "ื%1%2")
text = gsub(text, "ุ([ก-ฮ]ฺ?)([ัาิีึืุู])", "ู%1%2")
text = gsub(text, "ั([เโ])", "า%1")
text = gsub(text, "ิ([เโ])", "ี%1")
text = gsub(text, "ึ([เโ])", "ื%1")
text = gsub(text, "ุ([เโ])", "ู%1")
return text
end
return export