This module will transliterate text in the Fraser script. It is used to transliterate Zaiwa, Lisu, and Naxi.
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:Lisu-translit/testcases.
tr(text, lang, sc)
text
written in the script specified by the code sc
, and language specified by the code lang
.nil
.--[==[
Transliteration scheme is that used in David Bradley's Southern Lisu Dictionary (2006): https://stedt.berkeley.edu/pubs_and_prods/STEDT_Monograph4_Southern-Lisu-Dict.pdf ]==]
local export = {}
local gsub = mw.ustring.gsub
local oneChar = {
= "b", = "p", = "pʰ", = "d", = "t", = "tʰ", = "g", = "k", = "kʰ", = "dʒ", = "tʃ", = "tʃʰ", = "dz", = "ts", = "tsʰ", = "m", = "n", = "l", = "s", = "ʐ", = "z", = "ŋ", = "h̃", = "x", = "h", = "f", = "w", = "ʃ", = "j", = "jʰ", = "ɣ",
= "ɑ", = "æ", = "e", = "ø", = "i", = "o", = "u", = "y", = "ɯ", = "ɤ",
= "́", = "̌", = "̱", = "", = "̱̀", = "̀",
= "̃", = "ɑ",
= ",", = ".",
}
local twoChars = {
= "ɲ",
}
local threeChars = {
= "dʐɑ", = "tʂɑ", = "tʂʰɑ", = "ʂɑ",
= "dʒɑ", = "tʃɑ", = "tʃʰɑ", = "ʃɑ",
= "ꓺꓽ?"
}
function export.tr(text, lang, sc)
local UTF8_char = "*"
text = gsub(text, "()()(+)", "%1%3%2")
text = gsub(text, "()()()", "%1%3%2")
text = gsub(text, "%f+%f", "%0ꓮ")
text = gsub(text, "ˍ%f", "%0ꓺ")
text = gsub(text, "()()()", "%1%2%1%3")
text = gsub(text, "%f()", "ɣ%1")
text = gsub(text, "ꓮ(+)()", "%2%1")
text = gsub(text, "()ꓲ", "%1ɨ")
text = gsub(text, "()ꓵ", "%1ɨ")
text = gsub(text, "()ꓬ(ꓲ)", "%1%2")
text = gsub(text, "()ꓬ(ꓵ)", "%1%2")
text = gsub(text, "(?)ꓲ%f", "%1j")
text = gsub(text, "(?)ꓳ%f", "%1w")
text = gsub(text, "()(ꓮ?)%f", "%1\1%2")
for trigraph, replacement in pairs(threeChars) do
text = text:gsub(trigraph, replacement)
end
for digraph, replacement in pairs(twoChars) do
text = text:gsub(digraph, replacement)
end
return (text:gsub(UTF8_char, oneChar))
end
return export