Module:ady-translit

Definition from Wiktionary, the free dictionary
Jump to: navigation, search

This module will transliterate Adyghe language text per WT:ADY TR.

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:ady-translit/testcases.

Functions[edit]

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", ["в"]="v", ["г"]="ɣ", ["д"]="d", ["е"]="e", ["ё"]="ë", ["ж"]="ž",
	["з"]="z", ["и"]="i", ["й"]="j", ["к"]="k", ["л"]="l", ["м"]="m", ["н"]="n", ["о"]="o", 
	["п"]="p", ["р"]="r", ["с"]="s", ["т"]="t", ["у"]="w", ["ф"]="f", ["х"]="x", ["ц"]="c", 
	["ч"]="č", ["ш"]="š", ["щ"]="š̍", ["ъ"]="”", ["ы"]="ə", ["ь"]="’", ["э"]="ă", ["ю"]="ju",
	["я"]="jā", ["ӏ"]="ʾ", ["А"]="Ā", ["Б"]="B", ["В"]="V", ["Г"]="Ɣ", ["Д"]="D", ["Е"]="E", 
	["Ё"]="Ë", ["Ж"]="Ž", ["З"]="Z", ["И"]="I", ["Й"]="J", ["К"]="K", ["Л"]="L", ["М"]="M", 
	["Н"]="N", ["О"]="O", ["П"]="P", ["Р"]="R", ["С"]="S", ["Т"]="T", ["У"]="W", ["Ф"]="F", 
	["Х"]="X", ["Ц"]="C", ["Ч"]="Č", ["Ш"]="Š", ["Щ"]="Š̍", ["Ъ"]="”", ["Ы"]="Ə", ["Ь"]="’",
	["Э"]="Ă", ["Ю"]="Ju", ["Я"]="Jā", ["Ӏ"]="ʾ"};

local triQuadrigraphs = {
	['кхъу'] = 'q°',
	['Кхъу'] = 'Q°',
	['гъу'] = 'ġ°',
	['дзу'] = 'ʒ°',
	['жъу'] = 'ẑ°',
	['Кхъ'] = 'Q',
	['кхъ'] = 'q',
	['къу'] = 'q°',
	['кӏу'] = 'ḳ°',
	['пӏу'] = 'ṗ°',
	['тӏу'] = 'ṭ°',
	['хъу'] = 'χ°',
	['шъу'] = 'ŝ°',
	['шӏу'] = 'ṣ̂°',
	['гу'] = 'g°',
	['Гъу'] = 'Ġ°',
	['Дзу'] = 'Ʒ°',
	['Жъу'] = 'Ẑ°',
	['Къу'] = 'Q°',
	['Кӏу'] = 'Ḳ°',
	['Пӏу'] = 'Ṗ°',
	['Тӏу'] = 'Ṭ°',
	['Хъу'] = 'Χ°',
	['Шъу'] = 'Ŝ°',
	['Шӏу'] = 'Ṣ̂°',
}

local digraphs = {
	['гь'] = 'ɡ’',
	['гъ'] = 'ġ',
	['дж'] = 'ǯ̍',
	['дз'] = 'ʒ',
	['жъ'] = 'ẑ',
	['жь'] = 'ž̍',
	['ку'] = 'k°',
	['къ'] = 'q',
	['кӏ'] = 'č̣̍',
	['лъ'] = 'ł',
	['лӏ'] = 'ḷ',
	['пӏ'] = 'ṗ',
	['сӏ'] = 'ṣ̣',
	['тӏ'] = 'ṭ',
	['фӏ'] = 'f̣',
	['ху'] = 'x°',
	['хъ'] = 'χ',
	['хь'] = 'ḥ',
	['цу'] = 'c°',
	['цӏ'] = 'c̣',
	['чӏ'] = 'č̣',
	['чу'] = 'č̍°',
	['чъ'] = 'č',
	['шъ'] = 'ŝ',
	['шӏ'] = 'ṣ̂',
	['ӏу'] = 'ʾ°',
	['ӏь'] = '՚̍',
	['Гу'] = 'G°',
	['Гь'] = 'ɡ’',
	['Гъ'] = 'Ġ',
	['Дж'] = 'Ǯ̍',
	['Дз'] = 'Ʒ',
	['Жъ'] = 'Ẑ',
	['Жь'] = 'Ž̍',
	['Ку'] = 'K°',
	['Къ'] = 'Q',
	['Кӏ'] = 'Č̣̍',
	['Лъ'] = 'Ł',
	['Лӏ'] = 'Ḷ',
	['Пӏ'] = 'Ṗ',
	['Сӏ'] = 'Ṣ̣',
	['Тӏ'] = 'Ṭ',
	['Фӏ'] = 'F̣',
	['Ху'] = 'X°',
	['Хъ'] = 'Χ',
	['Хь'] = 'Ḥ',
	['Цу'] = 'C°',
	['Цӏ'] = 'C̣',
	['Чӏ'] = 'Č̣',
	['Чу'] = 'Č̍°',
	['Чъ'] = 'Č',
	['Шъ'] = 'Ŝ',
	['Шӏ'] = 'Ṣ̂',
}

function export.tr(text, lang, sc)
	for comb, repl in pairs(triQuadrigraphs) do
		text = mw.ustring.gsub(text, comb, repl)
	end
	for comb, repl in pairs(digraphs) do
		text = mw.ustring.gsub(text, comb, repl)
	end
	
	text = mw.ustring.gsub(text, '.', tt)
	
	return text
end

return export