Pergi ke kandungan

Modul:ab-translit

Daripada Wikikamus

Modul ini akan mentransliterasi Bahasa Abkhaz teks. 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:ab-translit/testcases.

Functions

[sunting]
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.

--[[
Transliterasi bagi bahasa Abkhaz.
]]
local export = {}
 
local tt = {
	["А"]='Ā', ["а"]='ā', ["Б"]='B', ["б"]='b', ["В"]='V', ["в"]='v', ["Г"]='G', ["г"]='g', 
	["Ӷ"]='Γ', ["ӷ"]='γ', ["Д"]='D', ["д"]='d', ["Џ"]='Ǯ', ["џ"]='ǯ', ["Е"]='E', ["е"]='e',
	["Ҽ"]='Č', ["ҽ"]='č', ["Ҿ"]='Č̣', ["ҿ"]='č̣',  ["Ж"]='Ž', ["ж"]='ž', ["З"]='Z', ["з"]='z',
	["Ӡ"]='Ʒ', ["ӡ"]='ʒ', ["И"]='I', ["и"]='i', ["К"]='Ḳ', ["к"]='ḳ', ["Қ"]='K', ["қ"]='k',
	["Ҟ"]='Q̇', ["ҟ"]='q̇', ["Л"]='L', ["л"]='l', ["М"]='M', ["м"]='m', ["Н"]='N', ["н"]='n',
	["О"]='O', ["о"]='o', ["Ҩ"]='ʿ°', ["ҩ"]='ʿ°', ["П"]='Ṗ', ["п"]='ṗ', ["Ԥ"]='P', ["ԥ"]='p',
	["Р"]='R', ["р"]='r', ["С"]='S', ["с"]='s', ["Т"]='Ṭ', ["т"]='ṭ', ["Ҭ"]='T', ["ҭ"]='t', 
	["У"]='U', ["у"]='u', ["Ф"]='F', ["ф"]='f', ["Х"]='X', ["х"]='x', ["Ҳ"]='Ḥ', ["ҳ"]='ḥ', 
	["Ц"]='C', ["ц"]='c', ["Ҵ"]='C̣', ["ҵ"]='c̣',  ["Ч"]='Č̍', ["ч"]='č̍', ["Ҷ"]='Č̣̍', ["ҷ"]='č̣̍', 
	["Ш"]='Š', ["ш"]='š', ["Ы"]='Ə', ["ы"]='ə', ["Ь"]='’', ["ь"]='’', ["Ә"]='W', ["ә"]='w',	 
	-- obsolete letters, still in use
	["Ҕ"]='Γ', ["ҕ"]='γ', ["Ҧ"]='P', ["ҧ"]='p',
	-- in borrowings from Russian and other languages
	["Ё"]="Ë", ['ё']='ë', ["Й"]='J', ["й"]='j', ["Ъ"]="ʺ", ['ъ']='ʺ', ["Э"]="È", ['э']='è',
	["Ю"]='Ju', ["ю"]='ju', ["Я"]='Ja', ["я"]='ja'
};

function export.tr(text, lang, sc)
	text = mw.ustring.gsub(text, 'дә', 'd°')
	text = mw.ustring.gsub(text, 'Дә', 'D°')
	text = mw.ustring.gsub(text, 'ҭә', 't°')
	text = mw.ustring.gsub(text, 'Ҭә', 'T°')
	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, 'цә', 'c°')
	text = mw.ustring.gsub(text, 'Цә', 'C°')
	text = mw.ustring.gsub(text, 'ҵә', 'c̣°')
	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, 'шь', 'š̍')
	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, 'гь', 'g̍')
	text = mw.ustring.gsub(text, 'Гь', 'G̍')
	text = mw.ustring.gsub(text, 'қь', 'k̍')
	text = mw.ustring.gsub(text, 'Қь', 'K̍')
	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, 'хь', 'x̍')
	text = mw.ustring.gsub(text, 'Хь', 'X̍')
	text = mw.ustring.gsub(text, 'гу', 'g°')
	text = mw.ustring.gsub(text, 'Гу', 'G°')
	text = mw.ustring.gsub(text, 'қу', 'k°')
	text = mw.ustring.gsub(text, 'Қу', 'K°')
	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, 'ху', 'x°')
	text = mw.ustring.gsub(text, 'Ху', 'X°')
	text = mw.ustring.gsub(text, 'ҟь', 'q̇̍')
	text = mw.ustring.gsub(text, 'Ҟь', 'Q̇̍')
	text = mw.ustring.gsub(text, 'ҟу', 'q̇°')
	text = mw.ustring.gsub(text, 'Ҟу', 'Q̇°̍')
	text = mw.ustring.gsub(text, 'ҳу', 'h°̍')
	text = mw.ustring.gsub(text, 'Ҳу', 'H°')
	text = mw.ustring.gsub(text, '.', tt)
	
	return text
end

return export