This module will transliterate text in the Tai Nüa script. It is used to transliterate Tai Nüa.
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:Tale-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 gsub = mw.ustring.gsub
local u = require("Module:string/char")
local export = {}
-- pattern ()(?)(?)(?)
local tt = {
-- consonants
= "k", = "x", = "ng", = "ts", = "s", = "y",
= "t", = "th", = "l", = "p", = "ph", = "m",
= "f", = "w", = "h", = "ʼ", = "kh", = "tsh", = "n",
-- vowels
= "aa", = "i", = "e", = "ae", = "u",
= "o", = "oa", = "ue", = "oe", = "aue",
= "y",
}
local tone_table = {
-- different ordering from Unicode: http://www.seasite.niu.edu/tai/TaiDehong/index.htm
-- also supports old orthography
= u(0x0308), = u(0x0308), = u(0x0308), -- 2 ä
= u(0x030C), = u(0x030C), = u(0x030C), -- 3 ǎ
= u(0x0300), = u(0x0300), = u(0x0300), = u(0x0300), -- 4 à
= u(0x0307), = u(0x0307), = u(0x0307), -- 5 ȧ
= u(0x0301), = u(0x0301), = u(0x0301), = u(0x0301), -- 1 á
= "", -- 6 a
}
local tone_key = "([ᥰ-ᥴ"
.. u(0x0308) .. u(0x00A8)
.. u(0x030C) .. u(0x02C7)
.. u(0x0300) .. u(0x0060) .. u(0x02CB)
.. u(0x0307) .. u(0x02D9)
.. u(0x0301) .. u(0x00B4) .. u(0x02CA) .. "]?)"
function export.tr(text, lang, sc)
if type(text) == "table" then -- called directly from a template
text = text.args
end
text = gsub(text, "()()", "%1a%2")
text = gsub(text, ".", tt)
-- adds tone diacritic
local new
for old in mw.text.gsplit(text, " ") do
new = gsub(old, "()(*)" .. tone_key, function(v, x, t)
return v .. tone_table .. x
end)
text = gsub(text, old, new, 1)
end
return text
end
return export