বিষয়বস্তুতে চলুন

মডিউল:tab-translit

উইকিঅভিধান, মুক্ত অভিধান থেকে

এই মডিউলের জন্য মডিউল:tab-translit/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে

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", 
	["ё"]="ë", ["ь"]="’", ["э"]="e", ["ю"]="ju", ["я"]="ja",
	["Б"]="B", ["П"]="P", ["Ф"]="F", ["В"]="V", ["М"]="M",
	["Д"]="D", ["Т"]="T", ["Й"]="J", ["Н"]="N", ["З"]="Z", ["Ц"]="C",
	["С"]="S", ["Ж"]="Ž", ["Ш"]="Š", ["Щ"]="Šč", 
	["Л"]="L", ["Ч"]="Č", ["Р"]="R", ["Г"]="G", ["К"]="K", ["Х"]="Χ", 
	["Ъ"]="ʾ", ["А"]="A", ["Е"]="E", ["Ы"]="Y", ["И"]="I", ["О"]="O", ["У"]="U", 
	["Ё"]="Ë", ["Ь"]="’", ["Э"]="E", ["Ю"]="Ju", ["Я"]="Ja"};

local trigraphs = {
	['хъв'] = 'q°',
	['Хъв'] = 'Q°',
	['къв'] = 'q̄°',
	['Къв'] = 'Q̄°',
	['кьв'] = 'q̇°',
	['Кьв'] = 'Q̇°',
	['гъв'] = 'ġ°',
	['Гъв'] = 'Ġ°',
	['кӏв'] = 'ḳ°',
	['Кӏв'] = 'Ḳ°',
	['ккв'] = 'k̄°',
	['Ккв'] = 'K̄°',
}

local digraphs = {
	['жв'] = 'ž°',
	['Жв'] = 'Ž°',
	['чв'] = 'č°',
	['Чв'] = 'Č°',
	['жъ'] = 'č̄°',
	['Жъ'] = 'Č̄°',
	['чъ'] = 'č̣',
	['Чъ'] = 'Č̣',
	['шв'] = 'š°',
	['Шв'] = 'Š°',
	['хв'] = 'χ°',
	['Хв'] = 'Χ°',
	['пп'] = 'p̄',
	['пӏ'] = 'ṗ',
	['тт'] = 't̄',
	['Пп'] = 'P̄',
	['Пӏ'] = 'Ṗ',
	['Тт'] = 'T̄',
	['цӏ'] = 'c̣',
	['цц'] = 'c̄',
	['тӏ'] = 'ṭ',
	['чч'] = 'č̄',
	['чӏ'] = 'č̣',
	['кь'] = 'q̇',
	['кк'] = 'k̄',
	['кӏ'] = 'ḳ',
	['хъ'] = 'q',
	['къ'] = 'q̄',
	['гъ'] = 'ġ',
	['гь'] = 'h',
	['Цӏ'] = 'C̣',
	['Цц'] = 'C̄',
	['Тӏ'] = 'Ṭ',
	['Чч'] = 'Č̄',
	['Чӏ'] = 'Č̣',
	['Кь'] = 'Q̇',
	['Кк'] = 'K̄',
	['Кӏ'] = 'Ḳ',
	['Хъ'] = 'Q',
	['Къ'] = 'Q̄',
	['Гъ'] = 'Ġ',
	['Гь'] = 'H',
	['уь'] = 'u̱',
	['Уь'] = 'U̱',
	['хь'] = 'x',
	['Хь'] = 'X',
	['гв'] = 'g°',
	['Гв'] = 'G°',
	['кв'] = 'k°',
	['Кв'] = 'K°',
	['аь'] = 'a̱',
	['Аь'] = 'A̱',
}

function export.tr(text, lang, sc)
	local str_gsub = string.gsub
	local UTF8char = '[\1-\127\194-\244][\128-\191]*'
	
	-- Convert uppercase palochka to lowercase. Lowercase is found in tables
	-- above.
	text = str_gsub(text, mw.ustring.char(0x4C0), mw.ustring.char(0x4CF))
	
	for trigraph, translit in pairs(trigraphs) do
		text = str_gsub(text, trigraph, translit)
	end
	
	for digraph, translit in pairs(digraphs) do
		text = str_gsub(text, digraph, translit)
	end
	
	text = str_gsub(text, UTF8char, tt)
	
	return text
end

return export