Zum Inhalt springen

Modul:ba-translit

Vun Wiktionary

This module will transliterate Bashkir text per WT:BA TR through the function tr.


local export = {}
 
local tt = {
    ["ү"]="ü",  ['Ү']='Ü',  ["т"]="t",  ['Т']='T',  ["р"]="r",  ['Р']='R',  ["ф"]="f",  ['Ф']='F',  ["ө"]="ö", ['Ө']='Ö',
    ["ю"]="yu", ['Ю']='Yu', ["ш"]="š",  ['Ш']='Š',  ["ь"]="’",  ['Ь']='’',  ["ъ"]="ʺ",  ['Ъ']='ʺ',   ["н"]="n", ['Н']='N', 
    ["п"]="p",  ['П']='P',  ["й"]="y",  ['Й']='Y',  ["л"]="l",  ['Л']='L',  ["з"]="z",  ['З']='Z',  ["е"]="e", ['Е']='E', 
    ["г"]="g",  ['Г']='G',  ["б"]="b",  ['Б']='B',  ["у"]="u",  ['У']='U',  ["с"]="s",  ['С']='S',  ["х"]="x", ['Х']='X',
    ["ч"]="č",  ['Ч']='č',  ["щ"]="šč", ['Щ']='Šč', ["я"]="ya", ['Я']='Ya', ["ы"]="ï",  ['Ы']='Ï',  ["э"]="e", ['Э']='E', 
    ["м"]="m",  ['М']='M',  ["о"]="o",  ['О']='O',  ["и"]="i",  ['И']='I',  ["ё"]="yo", ['Ё']='Yo', ["ж"]="ž", ['Ж']='Ž',
    ["к"]="k",  ['К']='K',  ["д"]="d",  ['Д']='D',  ["в"]="v",  ['В']='V',  ["ц"]="ts", ['Ц']='Ts', ["а"]="a", ['А']='A',
    ["ң"]="ñ",  ['Ң']='Ñ',  ["ғ"]="ğ",  ['Ғ']='Ğ',  ["ҙ"]="ð",  ['Ҙ']='Đ',  ["ҡ"]="q",  ['Ҡ']='Q',  ["ҫ"]="θ", ['Ҫ']='Θ',
    ["һ"]="h",  ['Һ']='H',  ["ә"]="ä",  ['Ә']='Ä'
};
 
-- Transliterate any words or phrases
function export.tr(word)
    if type(word) == 'table' then -- called directly from a template
        word = word.args[1]
    end
 
    word = mw.ustring.gsub(word, "([АаЕеЭэЮюЯяӘәИиҮүУуӨөЫы])[үу]", "%1w") -- ү/у should be transliterated as w after vowels
    word = mw.ustring.gsub(
            word, "([АОӨӘУЫЕЯЁЮИЕаоөәуыэяёюиеъь%A][́̀]?)([Ее])",
            function(a,e) return a..(e=='е' and 'ye' or 'Ye') end
        ):gsub("^Е",'Ye'):gsub("^е",'ye');
    word = mw.ustring.gsub(word, '.', tt)
 
    return word
end
 
return export