This module will transliterate text in the New Tai Lue script. It is used to transliterate Lü.
The module should preferably not be called directly from templates or other modules.
To use it from a template, use {{xlit}}
.
Within a module, use Module:languages#Language:transliterate.
For testcases, see Module:Talu-translit/testcases.
tr(text, lang, sc)
text
written in the script specified by the code sc
, and language specified by the code lang
.nil
.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
= '¹', = '²',
-- 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)
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