local export = {}
local gsub = mw.ustring.gsub
local tt = {
-- consonants
= '˙’', = '’',
= 'k\204\135', = 'x\204\135', = 'n\204\135g', = 'k', = 'x', = 'ng',
= 't\204\135s', = 's\204\135', = 'y\204\135', = 'ts', = 's', = 'y',
= 't\204\135', = 't\204\135h', = 'n\204\135', = 't', = 'th', = 'n',
= 'p\204\135', = 'p\204\135h', = 'm\204\135', = 'p', = 'ph', = 'm',
= 'f\204\135', = 'v\204\135', = 'l\204\135', = 'f', = 'v', = 'l',
= 'h\204\135', = 'd\204\135', = 'b\204\135', = 'h', = 'd', = 'b',
= 'k\204\135w', = 'x\204\135w', = 'kw', = 'xw', = 's\204\135w', = 'sw',
-- vowels and finals (visual ordering by Unicode 8)
= '!', = 'aa', = 'ii', = 'u', = 'uu', = 'oa', = 'ue',
= 'e', = 'ae', = 'o', = 'ay', -- this line to be swapped
= 'aay', = 'uy', = 'oy', = 'oay', = 'uey', = 'iiy',
= 'w', = 'ng', = 'n', = 'm', = 'k', = 'd', = 'b',
-- tones
= '<sup>1</sup>', = '<sup>2</sup>',
-- numerals
= '0', = '1', = '2', = '3', = '4',
= '5', = '6', = '7', = '8', = '9',
= '1',
-- ligatures ᧞ ᧟ sorted after ᦶᦜ
= 'l\204\135ae', = 'l\204\135aew',
}
function export.tr(text, lang, sc, debug_mode)
if type(text) == 'table' then -- called directly from a template
text = text.args
end
text = gsub(text, '()()', '%2%1') -- swapped
text = gsub(text, '()()', '%1a%2')
text = gsub(text, '.', tt)
text = gsub(text, 'aa!', 'a')
text = gsub(text, 'ii!', 'i')
text = gsub(text, 'uu!', 'u')
text = gsub(text, 'eii', 'oe')
return text
end
return export