Zum Inhalt springen

Modul:udm-translit

Vun Wiktionary

This module will transliterate Udmurt text per WT:UDM TR through the function tr.


-- This is a module to transliterate Udmurt Cyrillic words to Latin
 
local export = {}
 
function export.tr(word)
    if type(word) == 'table' then -- called directly from a template
        word = word.args[1]
    end
 
    -- Ё needs converting if is decomposed
    word = word:gsub("ё","ё"):gsub("Ё","Ё")
 
    -- е after a vowel or at the beginning of a word becomes je
    word = mw.ustring.gsub(word, "([АОӦУЫЕЯЁЮИӤЕЪЬаоӧуыэяёюиӥеъь%A][́̀]?)е","%1je")
    word = mw.ustring.gsub(word, "^Е","Je")
    word = mw.ustring.gsub(word, "^е","je")
    word = mw.ustring.gsub(word, "([^Ѐ-ӿ])Е","%1Je")
    word = mw.ustring.gsub(word, "([^Ѐ-ӿ])е","%1je")
 
    return (mw.ustring.gsub(word,'.',tab))
end
 
tab = {
    ["А"]="A", ["Б"]="B", ["В"]="V", ["Г"]="G", ["Д"]="D", ["Е"]="E", ["Ё"]="Jo", ["Ж"]="Ž", ["Ӝ"]="Dž", ["З"]="Z", ["Ӟ"]="Dź", ["И"]="I",
    ["Ӥ"]="Ï", ["Й"]="J", ["К"]="K", ["Л"]="L", ["М"]="M", ["Н"]="N", ["О"]="O", ["Ӧ"]="Ö", ["П"]="P", ["Р"]="R", ["С"]="S", ["Т"]="T",
    ["У"]="U", ["Ф"]="F", ["Х"]="X", ["Ц"]="C", ["Ч"]="Č", ["Ӵ"]="Ć", ["Ш"]="Š", ["Щ"]="Šč", ["Ъ"]="ʺ", ["Ы"]="Y", ["Ь"]="ʹ", ["Э"]="E",
    ["Ю"]="Ju", ["Я"]="Ja",
    ['а']='a', ['б']='b', ['в']='v', ['г']='g', ['д']='d', ['е']='e', ['ё']='jo', ['ж']='ž', ['ӝ']='dž', ['з']='z', ['ӟ']='dź', ['и']='i',
    ['ӥ']='ï', ['й']='j', ['к']='k', ['л']='l', ['м']='m', ['н']='n', ['о']='o', ['ӧ']='ö', ['п']='p', ['р']='r', ['с']='s', ['т']='t',
    ['у']='u', ['ф']='f', ['х']='x', ['ц']='c', ['ч']='č', ['ӵ']='ć', ['ш']='š', ['щ']='šč', ['ъ']='ʺ', ['ы']='y', ['ь']='ʹ', ['э']='e',
    ['ю']='ju', ['я']='ja',
}
 
return export