模組:Udm-translit

維基詞典,自由的多語言詞典

這個模組會將烏得穆爾特語未確定的文字拉丁化。

最好不要直接從模板或其他模組調用此模組。要從模板中使用它,請以{{xlit}}做為替代;若要在模組中使用,則以Module:languages#Language:transliterate替代。

關於測試用例,請參閱Module:Udm-translit/testcases

函數[编辑]

tr(text, lang, sc)
Transliterates a given piece of text written in the script specified by the code sc, and language specified by the code lang. When the transliteration fails, returns nil.

-- Transliteration for Udmurt 烏德穆爾特語轉譯

local export = {}

local tab = {
	["А"]="A", ["Б"]="B", ["В"]="V", ["Г"]="G", ["Д"]="D", ["Е"]="E", ["Ё"]="O", ["Ж"]="Ž", ["Ӝ"]="Dž", ["З"]="Z", ["Ӟ"]="Dź", ["И"]="I", ["Ӥ"]="I", ["Й"]="J",
	["К"]="K", ["Л"]="L", ["М"]="M", ["Н"]="N", ["О"]="O", ["Ӧ"]="Ö", ["П"]="P", ["Р"]="R", ["С"]="S", ["Т"]="T", ["У"]="U", ["Ф"]="F",
	["Х"]="X", ["Ц"]="C", ["Ч"]="Ć", ["Ӵ"]="Č", ["Ш"]="Š", ["Щ"]="Šč", ["Ъ"]="", ["Ы"]="Y", ["Ь"]="", ["Э"]="E", ["Ю"]="U", ["Я"]="A",
	['а']='a', ['б']='b', ['в']='v', ['г']='g', ['д']='d', ['е']='e', ['ё']='o', ['ж']='ž', ['ӝ']='dž', ['з']='z', ['ӟ']='dź', ['и']='i', ['ӥ']='i', ['й']='j',
	['к']='k', ['л']='l', ['м']='m', ['н']='n', ['о']='o', ['ӧ']='ö', ['п']='p', ['р']='r', ['с']='s', ['т']='t', ['у']='u', ['ф']='f',
	['х']='x', ['ц']='c', ['ч']='ć', ['ӵ']='č', ['ш']='š', ['щ']='šč', ['ъ']='', ['ы']='y', ['ь']='', ['э']='e', ['ю']='u', ['я']='a', 
	-- Beserman
	['Ө']='Å', ['ө']='å', ['Ў']='W', ['ў']='w',
}

function export.tr(text, lang, sc)
	local language = lang
    -- Ё needs converting if is decomposed
    text = text:gsub("ё","ё"):gsub("Ё","Ё")
    
    -- soft consonants
    text = mw.ustring.gsub(text, "([ДЗЛНСТдзлнст])([еёияюь])", "%1Q%2")
    if lang ~= "udm" then 
    	text = mw.ustring.gsub(text, "([БВГЖКМПРФХЦЧШЩбвгжкмпрфхцчшщ])([ёяюь])", "%1Q%2") 
    end

    -- soft vowels after a vowel or at the beginning of a word become j-
    text = mw.ustring.gsub(text, "([АОÖУЫЕЯЁЮИӤЕЪЬаоöуыэяёюиӥеъь%A][\204\129\204\128]?)([еёюя])", "%1j%2")
    text = mw.ustring.gsub(text, "^([ЕЁЮЯ])", "J%1")
    text = mw.ustring.gsub(text, "^([еёюя])", "j%1")
    
    -- palatalisation
    text = mw.ustring.gsub(text, "ДQ", "Ď")
    text = mw.ustring.gsub(text, "дQ", "ď")
    text = mw.ustring.gsub(text, "ЗQ", "Ź")
    text = mw.ustring.gsub(text, "зQ", "ź")
    text = mw.ustring.gsub(text, "ЛQ", "Ľ")
    text = mw.ustring.gsub(text, "лQ", "ľ")
    text = mw.ustring.gsub(text, "НQ", "Ń")
    text = mw.ustring.gsub(text, "нQ", "ń")
    text = mw.ustring.gsub(text, "СQ", "Ś")
    text = mw.ustring.gsub(text, "сQ", "ś")
    text = mw.ustring.gsub(text, "ТQ", "Ť")
    text = mw.ustring.gsub(text, "тQ", "ť")
    text = mw.ustring.gsub(text, "Q", "ʹ")
    
    return (mw.ustring.gsub(text,'.',tab))
end

return export