Module:inh-translit

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

This module will transliterate Ingush language text per WT:INH 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:inh-translit/testcases.

Functions[edit]

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

local export = {}

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

local mapping2 = {
	['аь'] = 'ä', ['гӏ'] = 'ġ' , ['кх'] = 'q', ['къ'] = 'q̇',
	['кӏ'] = 'ḳ', ['пӏ'] = 'ṗ' , ['тӏ'] = 'ṭ', ['цӏ'] = 'c̣',
	['чӏ'] = 'č̣', ['яь'] = 'jä', ['ий'] = 'ī', ['ув'] = 'ū',
	['хь'] = 'ḥ', ['хӏ'] = 'h' , ['Аь'] = 'Ä', ['Гӏ'] = 'Ġ',
	['Кх'] = 'Q', ['Къ'] = 'Q̇' , ['Кӏ'] = 'Ḳ', ['Пӏ'] = 'Ṗ',
	['Тӏ'] = 'Ṭ', ['Цӏ'] = 'C̣' , ['Чӏ'] = 'Č̣', ['Яь'] = 'Jä',
	['Ий'] = 'Ī', ['Ув'] = 'Ū' , ['Хь'] = 'Ḥ', ['Хӏ'] = 'H',
}

function export.tr(text, lang, sc)
	text = mw.ustring.gsub(text, 'рхӏ', 'ρ')
	text = mw.ustring.gsub(text, 'Рхӏ', 'Ρ')
	for pat, repl in pairs(mapping2) do
		text = mw.ustring.gsub(text, pat, repl)
	end
	text = mw.ustring.gsub(text, '.', mapping1)

	return text
end

return export