Pergi ke kandungan

Modul:lez-translit

Daripada Wikikamus

Modul ini akan mentransliterasi Bahasa Lezgi teks. 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:lez-translit/testcases.

Functions

[sunting]
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.

local export = {}

local tt = {
	["б"]="b", ["п"]="p", ["ф"]="f", ["в"]="v", ["м"]="m",
	["д"]="d", ["т"]="t", ["й"]="j", ["н"]="n", ["з"]="z", ["ц"]="c",
	["с"]="s", ["ж"]="ž", ["ш"]="š", ["щ"]="šč", 
	["л"]="l", ["ч"]="č", ["р"]="r", ["г"]="g", ["к"]="k", ["х"]="χ", 
	["ъ"]="ʾ", ["а"]="a", ["е"]="e", ["ы"]="y", ["и"]="i", ["о"]="o", ["у"]="u", 
	["ё"]="ë", ["ь"]="’", ["э"]="è", ["ю"]="ju", ["я"]="ä",
	["Б"]="B", ["П"]="P", ["Ф"]="F", ["В"]="V", ["М"]="M",
	["Д"]="D", ["Т"]="T", ["Й"]="J", ["Н"]="N", ["З"]="Z", ["Ц"]="C",
	["С"]="S", ["Ж"]="Ž", ["Ш"]="Š", ["Щ"]="Šč", 
	["Л"]="L", ["Ч"]="Č", ["Р"]="R", ["Г"]="G", ["К"]="K", ["Х"]="Χ", 
	["Ъ"]="ʾ", ["А"]="A", ["Е"]="E", ["Ы"]="Y", ["И"]="I", ["О"]="O", ["У"]="U", 
	["Ё"]="Ë", ["Ь"]="’", ["Э"]="È", ["Ю"]="Ju", ["Я"]="Ä"};

function export.tr(text, lang, sc)
	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, 'гъв', 'ġ°')
	text = mw.ustring.gsub(text, 'Гъв', 'Ġ°')
	text = mw.ustring.gsub(text, 'ттв', 't̄°')
	text = mw.ustring.gsub(text, 'Ттв', 't̄°')
	text = mw.ustring.gsub(text, 'ццв', 'c̄°')
	text = mw.ustring.gsub(text, 'Ццв', 'C̄°')
	text = mw.ustring.gsub(text, 'ккв', 'k̄°')
	text = mw.ustring.gsub(text, 'Ккв', 'K̄°')
	text = mw.ustring.gsub(text, 'тӏв', 'ṭ°')
	text = mw.ustring.gsub(text, 'Тӏв', 'Ṭ°')
	text = mw.ustring.gsub(text, 'цӏв', 'c̣°')
	text = mw.ustring.gsub(text, 'Цӏв', 'C̣°')
	text = mw.ustring.gsub(text, 'кӏв', 'ḳ°')
	text = mw.ustring.gsub(text, 'Кӏв', 'Ḳ°')
	text = mw.ustring.gsub(text, 'тв', 't°')
	text = mw.ustring.gsub(text, 'Тв', 'T°')
	text = mw.ustring.gsub(text, 'зв', 'z°')
	text = mw.ustring.gsub(text, 'Зв', 'Z°')
	text = mw.ustring.gsub(text, 'хв', 'χ°')
	text = mw.ustring.gsub(text, 'Хв', 'Χ°')
	text = mw.ustring.gsub(text, 'цв', 'c°')
	text = mw.ustring.gsub(text, 'Цв', 'C°')
	text = mw.ustring.gsub(text, 'св', 's°')
	text = mw.ustring.gsub(text, 'Св', 'S°')
	text = mw.ustring.gsub(text, 'пп', 'p̄')
	text = mw.ustring.gsub(text, 'пӏ', 'ṗ')
	text = mw.ustring.gsub(text, 'тт', 't̄') 
	text = mw.ustring.gsub(text, 'Пп', 'P̄')
	text = mw.ustring.gsub(text, 'Пӏ', 'Ṗ')
	text = mw.ustring.gsub(text, 'Тт', 'T̄')
	text = mw.ustring.gsub(text, 'цӏ', 'c̣')
	text = mw.ustring.gsub(text, 'цц', 'c̄')
	text = mw.ustring.gsub(text, 'тӏ', 'ṭ')
	text = mw.ustring.gsub(text, 'чч', 'č̄')
	text = mw.ustring.gsub(text, 'чӏ', 'č̣')
	text = mw.ustring.gsub(text, 'кь', 'q̇')
	text = mw.ustring.gsub(text, 'кк', 'k̄')
	text = mw.ustring.gsub(text, 'кӏ', 'ḳ')
	text = mw.ustring.gsub(text, 'хъ', 'q')
	text = mw.ustring.gsub(text, 'къ', 'q̄')
	text = mw.ustring.gsub(text, 'гъ', 'ġ')
	text = mw.ustring.gsub(text, 'гь', 'h')
	text = mw.ustring.gsub(text, 'Цӏ', 'C̣')
	text = mw.ustring.gsub(text, 'Цц', 'C̄')
	text = mw.ustring.gsub(text, 'Тӏ', 'Ṭ')
	text = mw.ustring.gsub(text, 'Чч', 'Č̄')
	text = mw.ustring.gsub(text, 'Чӏ', 'Č̣')
	text = mw.ustring.gsub(text, 'Кь', 'Q̇')
	text = mw.ustring.gsub(text, 'Кк', 'K̄')
	text = mw.ustring.gsub(text, 'Кӏ', 'Ḳ')
	text = mw.ustring.gsub(text, 'Хъ', 'Q')
	text = mw.ustring.gsub(text, 'Къ', 'Q̄')
	text = mw.ustring.gsub(text, 'Гъ', 'Ġ')
	text = mw.ustring.gsub(text, 'Гь', 'H')
	text = mw.ustring.gsub(text, 'уь', 'ü')
	text = mw.ustring.gsub(text, 'Уь', 'Ü')
	text = mw.ustring.gsub(text, 'хь', 'x')
	text = mw.ustring.gsub(text, 'Хь', 'X')
	text = mw.ustring.gsub(text, 'гв', 'g°')
	text = mw.ustring.gsub(text, 'Гв', 'G°')
	text = mw.ustring.gsub(text, 'кв', 'k°')
	text = mw.ustring.gsub(text, 'Кв', 'K°')
	text = mw.ustring.gsub(text, '.', tt)
	
	return text
end

return export