This module will transliterate text in the Mongolian script. It is used to transliterate Buryat, Classical Mongolian, Daur, Mongolian, Sanskrit, Dukhan, Classical Tibetan, Middle Mongol, and Khamnigan Mongol.
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:Mong-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 match = mw.ustring.match
local export = {}
local chars = {
= "a", = "e",
= "i",
= "o", = "u",
= "ö", = "ü",
= "ē",
= "n",
= "ng",
= "b", = "p",
= "q", = "ɣ",
= "m", = "l",
= "s", = "š",
= "t", = "d",
= "č", = "š̤",
= "ǰ", = "y", = "r",
= "w",
= "f",
= "k", = "k",
= "c", = "z",
= "h",
= "ř",
= "lh",
= "ž",
= "č̭",
= "0", = "1", = "2", = "3",
= "4", = "5", = "6", = "7",
= "8", = "9",
= "∞", = "…", = ",", = ".", = ":", = "::",
= "?", = "!",
= "-", = "-", = "-",
= "", = "", = "", = "",
}
local front_vowel = {
= "g",
= "k"
}
function export.tr(text, lang, sc)
if sc ~= "Mong" then
return nil
end
local bad_diphthong = match(text, "ᠥᠶ?ᠢ")
if bad_diphthong then
error("Diphthong " .. diphthong .. " does not exist. Please replace with " .. gsub(bad_diphthong, "ᠥ", "ᠦ") .. ".")
end
text = gsub(text, ".", chars)
text = gsub(text, "%f", front_vowel)
return text
end
return export