Module:ce-translit

Definition from Wiktionary, the free dictionary
Jump to: navigation, search
The following documentation is located at Module:ce-translit/documentation. [edit]

This module will transliterate Chechen language text per WT:CE 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:ce-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 tt = {
	["а"]="a", ["б"]="b", ["в"]="w", ["г"]="g", ["д"]="d", ["е"]="ie", ["ё"]="ë",
	["ж"]="ž", ["з"]="z", ["и"]="i", ["й"]="j", ["к"]="k", ["л"]="l", ["м"]="m",
	["н"]="n", ["о"]="o", ["п"]="p", ["р"]="r", ["с"]="s", ["т"]="t", ["у"]="u",
	["ф"]="f", ["х"]="χ", ["ц"]="c", ["ч"]="č", ["ш"]="š", ["щ"]="šč", ["ъ"]="ʾ", ["ы"]="y",
	["ь"]="’", ["э"]="e", ["ю"]="ju", ["я"]="ja", ["ӏ"]="ʿ", ["А"]="A", ["Б"]="B", 
	["В"]="W", ["Г"]="G", ["Д"]="D", ["Е"]="Ie", ["Ё"]="Ë", ["Ж"]="Ž", ["З"]="Z", 
	["И"]="I", ["Й"]="J", ["К"]="K", ["Л"]="L", ["М"]="M", ["Н"]="N", ["О"]="O", 
	["П"]="P", ["Р"]="R", ["С"]="S", ["Т"]="T", ["У"]="U", ["Ф"]="F", ["Х"]="Χ", 
	["Ц"]="C", ["Ч"]="Č", ["Ш"]="Š", ["Щ"]="Šč", ["Ъ"]="ʾ", ["Ы"]="Y", ["Ь"]="’", ["Э"]="E", 
	["Ю"]="Ju", ["Я"]="Ja", ["Ӏ"]="ʿ"};
 
function export.tr(text, lang, sc)
	text = mw.ustring.gsub(text, 'аь', 'ä')
	text = mw.ustring.gsub(text, 'гӏ', 'ġ')
	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, 'къ', 'q̇')
	text = mw.ustring.gsub(text, 'кӏ', 'ḳ')
	text = mw.ustring.gsub(text, 'оь', 'ö')
	text = mw.ustring.gsub(text, 'пӏ', 'ṗ')
	text = mw.ustring.gsub(text, 'тӏ', 'ṭ')
	text = mw.ustring.gsub(text, 'уь', 'ü')
	text = mw.ustring.gsub(text, 'хь', 'ḥ')
	text = mw.ustring.gsub(text, 'хӏ', 'h')
	text = mw.ustring.gsub(text, 'цӏ', 'c̣')
	text = mw.ustring.gsub(text, 'чӏ', 'č̣')
	text = mw.ustring.gsub(text, 'юь', 'jü')
	text = mw.ustring.gsub(text, 'яь', 'jä')
	text = mw.ustring.gsub(text, 'Аь', 'Ä')
	text = mw.ustring.gsub(text, 'Гӏ', 'Ġ')
	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, 'Къ', 'Q̇')
	text = mw.ustring.gsub(text, 'Кӏ', 'Ḳ')
	text = mw.ustring.gsub(text, 'Оь', 'Ö')
	text = mw.ustring.gsub(text, 'Пӏ', 'Ṗ')
	text = mw.ustring.gsub(text, 'Тӏ', 'Ṭ')
	text = mw.ustring.gsub(text, 'Уь', 'Ü')
	text = mw.ustring.gsub(text, 'Хь', 'Ḥ')
	text = mw.ustring.gsub(text, 'Хӏ', 'H')
	text = mw.ustring.gsub(text, 'Цӏ', 'C̣')
	text = mw.ustring.gsub(text, 'Чӏ', 'Č̣')
	text = mw.ustring.gsub(text, 'Юь', 'Jü')
	text = mw.ustring.gsub(text, 'Яь', 'Jä')
	text = mw.ustring.gsub(text, '.', tt)
 
	return text
end
 
return export