local export = {}
local conv = {
-- finals (U+A980 - U+A983):
= "m",
= "ng",
= "r",
= "h",
-- independent vowels (U+A984 - U+A98E):
= "a", = "a",
= "i",
= "i",
= "i",
= "u", = "u",
= "re", = "reu",
= "le",
= "leu",
= "e",
= "ai",
= "o",
-- independent consonants (U+A98F - U+A9B2):
= "k", = "kh",
= "q",
= "kh",
= "g", = "gh",
= "gh",
= "ng", = "'",
= "c",
= "ch",
= "j", = "z",
= "jny",
= "jh",
= "ny",
= "th",
= "th",
= "dh",
= "dh",
= "nn",
= "t",
= "th",
= "d", = "dz",
= "dh",
= "n",
= "p", = "f",
= "ph",
= "b",
= "bh",
= "m",
= "y",
= "r",
= "r",
= "l",
= "w", = "v",
= "sh",
= "ss",
= "s", = "sy",
= "h", = "h",
-- cecak_telu/nukta (U+A9B3):
= "",
-- dependent vowels (U+A9B4 - A9BD):
= "a", -- tarung
= "o",
= "i",
= "i",
= "u",
= "ū",
= "é", = "o",
= "ai", = "au",
= "e",
= "re", = "reu",
-- medials (U+A9BE - U+A9BF):
= "y",
= "r",
-- pangkon/virama (U+A9C0):
= "",
-- punctuation (U+A9C1 - U+A9CF):
= "(starts title)",
= "(ends title)",
= "(letter to younger age or lower rank)",
= "(letter to equal age or equal rank)",
= "(letter to older age or higher rank)",
= "(pada windu)",
= ":", -- number indicator
= ",",
= ".",
= "\"",
= "//",
= "(",
= ")",
= "<sup>2</sup>",
-- digits (U+A9D0 - U+A9D9):
= "0",
= "1",
= "2",
= "3",
= "4",
= "5",
= "6",
= "7",
= "8",
= "9",
-- ellipsis (U+A9DE - U+A9DF):
= "-",
= "-",
}
function export.tr(text, lang, sc)
local CSVC = {
initial = "(꦳?)",
medial = "(?)",
nucleus = "(?ꦴ?)",
final = "(?)",
}
local VC = {
nucleus = "(ꦴ?)",
final = "(*)",
}
local number_indicator = "꧇"
local digits = ""
local initial = true
text = mw.ustring.gsub(
text,
CSVC.initial .. CSVC.medial .. CSVC.nucleus.. CSVC.final,
function(a, b, c, d)
a = conv or error("Initial not recognized: " .. a)
b = b == "" and "" or conv or error("Medial not recognized: " .. b)
c = c == "" and "a" or conv or error("Nucleus not recognized: " .. c)
d = d == "" and "" or conv or error("Final not recognized: " .. d)
if initial and a == "h" then
a = ""
end
initial = false
return a .. b .. c .. d
end
)
text = mw.ustring.gsub(
text,
VC.nucleus .. VC.final,
function(a, b)
a = conv
b = (b == "" and "" or conv)
initial = false
return a .. b
end
)
text = mw.ustring.gsub(
text,
number_indicator .. "(" .. digits .. "+)" .. number_indicator,
function(a)
a = mw.ustring.gsub(a, ".", conv)
initial = true
return a
end
)
text = mw.ustring.gsub(text, ".", conv)
return text
end
return export