Module:kbd-translit

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

This module will transliterate Kabardian language text per WT:KBD 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:kbd-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 = {
	["а"]="ā", ["б"]="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ā", ["Ӏ"]="ʾ"};
 
function export.tr(text)
	text = mw.ustring.gsub(text, 'кхъу', 'q°')
	text = mw.ustring.gsub(text, 'Кхъу', 'Q°')
	text = mw.ustring.gsub(text, 'гъу', 'ġ°')
	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, 'гу', 'g°')
	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, 'ку', 'k°')
	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, 'фӏ', 'f̣')
	text = mw.ustring.gsub(text, 'ху', 'x°')
	text = mw.ustring.gsub(text, 'хъ', 'χ')
	text = mw.ustring.gsub(text, 'хь', 'ḥ')
	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, 'Гъу', 'Ġ°')
	text = mw.ustring.gsub(text, 'Къу', 'Q̇°')
	text = mw.ustring.gsub(text, 'Кӏу', 'Ḳ°')
	text = mw.ustring.gsub(text, 'Хъу', 'Χ°')
	text = mw.ustring.gsub(text, 'Гу', 'G°')
	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, 'Ку', 'K°')
	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, 'Фӏ', 'F̣')
	text = mw.ustring.gsub(text, 'Ху', 'X°')
	text = mw.ustring.gsub(text, 'Хъ', 'Χ')
	text = mw.ustring.gsub(text, 'Хь', 'Ḥ')
	text = mw.ustring.gsub(text, 'Цӏ', 'C̣')
	text = mw.ustring.gsub(text, 'Чу', 'Č̍°')
	text = mw.ustring.gsub(text, 'Щӏ', 'Ṣ̂')
	text = mw.ustring.gsub(text, '.', tt)
 
	return text
end
 
return export