Module:xwo-translit
Jump to navigation
Jump to search
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate Written Oirat language text. It is also used to transliterate Classical Tibetan.
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:xwo-translit/testcases.
Functions
[edit]tr(text, lang, sc)
- Transliterates a given piece of
text
written in the script specified by the codesc
, and language specified by the codelang
. - When the transliteration fails, returns
nil
.
local export = {}
local MACRON = mw.ustring.char(0x0304)
local tt = {
["ᠠ"] = "a", ["ᡄ"] = "e", ["ᡅ"] = "i", ["ᡆ"] = "o", ["ᡇ"] = "u",
["ᡈ"] = "ö", ["ᡉ"] = "ü",
["ᡋ"] = "b", ["ᡌ"] = "p", ["ᡏ"] = "m", ["ᠯ"] = "l",
["ᠰ"] = "s", ["ᠱ"] = "š", ["ᠨ"] = "n", ["ᡍ"] = "x",
["ᡎ"] = "ɣ", ["ᡐ"] = "t", ["ᡑ"] = "d", ["ᡔ"] = "c",
["ᡒ"] = "č", ["ᡓ"] = "ǰ", ["ᡕ"] = "y", ["ᠷ"] = "r",
["ᡖ"] = "w", ["ᡙ"] = "h", ["ᡘ"] = "gh", ["ᡗ"] = "q",
["ᡚ"] = "ž", ["ᡛ"] = "ń", ["ᡜ"] = "dz", ["ᡊ"] = "ng",
["ᠴ"] = "z",
["ᡃ"] = MACRON, [""] = "-", ["︖"] = "?", ["︕"] = "!",
["᠂"] = ",", ["᠃"] = ".", [" "] = "-", ["᠊"] = "-"
}
function export.tr(text, lang, sc)
local velar_conv = { ["x"] = "k", ["ɣ"] = "g" }
text = mw.ustring.gsub(text, ".", tt)
text = mw.ustring.gsub(text, "([xɣ])(.?)", function(velar, vowel)
return ((mw.ustring.match(vowel, "[eiöü ]") or vowel == "")
and mw.ustring.gsub(velar, "[xɣ]", velar_conv) or velar) .. vowel end)
text = mw.ustring.gsub(text, "zi", "ji")
return text
end
return export