มอดูล:mn-translit
- The following documentation is located at มอดูล:mn-translit/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate ภาษามองโกเลีย text.
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:mn-translit/testcases.
Functions
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 trfunc = {}
local tt_Cyrl = {
["Щ"] = "Šč", ["щ"] = "šč", ["Ы"] = "Y", ["ы"] = "y", ["Э"] = "E", ["э"] = "e",
["Я"] = "Ja", ["я"] = "ja", ["У"] = "U", ["у"] = "u", ["С"] = "S", ["с"] = "s",
["Ч"] = "Č", ["ч"] = "č", ["Х"] = "H", ["х"] = "h", ["Ж"] = "Ž", ["ж"] = "ž",
["Д"] = "D", ["д"] = "d", ["В"] = "V", ["в"] = "v", ["А"] = "A", ["а"] = "a",
["М"] = "M", ["м"] = "m", ["О"] = "O", ["о"] = "o", ["И"] = "I", ["и"] = "i",
["К"] = "K", ["к"] = "k", ["Ш"] = "Š", ["ш"] = "š", ["Ъ"] = "ʺ", ["ъ"] = "ʺ",
["Ё"] = "Jo", ["ё"] = "jo", ["Ь"] = "ʹ", ["ь"] = "ʹ", ["Ю"] = "Ju", ["ю"] = "ju",
["Т"] = "T", ["т"] = "t", ["Р"] = "R", ["р"] = "r", ["Ц"] = "Ts", ["ц"] = "ts",
["Ф"] = "F", ["ф"] = "f", ["З"] = "Z", ["з"] = "z", ["Е"] = "E", ["е"] = "e",
["Г"] = "G", ["г"] = "g", ["Б"] = "B", ["б"] = "b", ["Н"] = "N", ["н"] = "n",
["П"] = "P", ["п"] = "p", ["Й"] = "J", ["й"] = "j", ["Л"] = "L", ["л"] = "l",
["Ү"] = "Ü", ["ү"] = "ü", ["Ө"] = "Ö", ["ө"] = "ö"
}
local tt_Mong = {
["ᠠ"] = "a", ["ᠡ"] = "e", ["ᠢ"] = "i", ["ᠣ"] = "o", ["ᠤ"] = "u",
["ᠥ"] = "ö", ["ᠦ"] = "ü", ["ᠧ"] = "ē",
["ᠨ"] = "n", ["ᠩ"] = "ng", ["ᠪ"] = "b", ["ᠫ"] = "p",
["ᠬ"] = "q", ["ᢉ"] = "k", ["ᠭ"] = "ɣ", ["ᢉ"] = "g",
["ᠮ"] = "m", ["ᠯ"] = "l", ["ᠰ"] = "s", ["ᠱ"] = "š",
["ᠲ"] = "t", ["ᠳ"] = "d", ["ᠴ"] = "č", ["ᠵ"] = "ǰ",
["ᠶ"] = "y", ["ᠷ"] = "r", ["ᠸ"] = "w", ["ᠹ"] = "f",
["ᠺ"] = "g", ["ᠻ"] = "k", ["ᠼ"] = "c", ["ᠽ"] = "z",
["ᠾ"] = "h", ["ᠿ"] = "ž", ["ᡀ"] = "lh", ["ᡁ"] = "zh", ["ᡂ"] = "ch",
[""] = "-", ["︖"] = "?", ["︕"] = "!", ["᠂"] = ",", ["᠃"] = ".", [" "] = "-", ["᠊"] = "-"
}
function trfunc.Cyrl(text)
text = mw.ustring.gsub(text, "([АОУЫЕЯЁЮИЕЪЬаоуыэяёюиеъь%A][\204\129\204\128]?)([Ее])",
function (a, e)
return a .. (e == "е" and "je" or "Je")
end):gsub("^Е", "Je"):gsub("^е", "je")
return (mw.ustring.gsub(text, ".", tt_Cyrl))
end
function trfunc.Mong(text)
local velar_conv = { ["q"] = "k", ["ɣ"] = "g" }
text = mw.ustring.gsub(text, ".", tt_Mong)
text = mw.ustring.gsub(text, "([qɣ])(.?)", function(velar, vowel)
return ((mw.ustring.match(vowel, "[eöü ]") or vowel == "")
and mw.ustring.gsub(velar, "[qɣ]", velar_conv) or velar) .. vowel end)
return text
end
function export.tr(text, lang, sc)
if not sc then
sc = require("Module:scripts").findBestScript(text, require("Module:languages").getByCode("mn"))
if sc then
sc = sc:getCode()
else
return nil
end
end
local func = trfunc[sc]
if func then
return trfunc[sc](text)
end
end
return export