Module:Mn-translit

--[[
Transliteration for Mongolian.
]]
local M={}

local tt={
    ["Щ"]="Šč",['щ']='šč', ["Ы"]="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',   ["Ү"]="Ü",['ү']='ü', ["Ө"]="Ö",['ө']='ö'
};

function M.tr(text)--translit any words or phrases
    if type(text) == "table" then text = text.args[1] end
 
    text = mw.ustring.gsub(
            text,   "([АОУЫЕЯЁЮИЕЪЬаоуыэяёюиеъь%A][́̀]?)([Ее])",
            function(a,e) return a..(e=='е' and 'je' or 'Je') end
        ):gsub("^Е",'Je'):gsub("^е",'je');
    return (mw.ustring.gsub(text, '.', tt))
end

return M