Module:bg-translit

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

This module will transliterate Bulgarian language text per WT:BG 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:bg-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', ["а"]='a', ["Б"]='B', ["б"]='b', ["В"]='V', ["в"]='v', ["Г"]='G', ["г"]='g', ["Д"]='D', ["д"]='d', 
	["Е"]='E', ["е"]='e', ["Ж"]='Ž', ["ж"]='ž', ["З"]='Z', ["з"]='z', ["И"]='I', ["и"]='i', ["Й"]='J', ["й"]='j', 
	["К"]='K', ["к"]='k', ["Л"]='L', ["л"]='l', ["М"]='M', ["м"]='m', ["Н"]='N', ["н"]='n', ["О"]='O', ["о"]='o', 
	["П"]='P', ["п"]='p', ["Р"]='R', ["р"]='r', ["С"]='S', ["с"]='s', ["Т"]='T', ["т"]='t', ["У"]='U', ["у"]='u', 
	["Ф"]='F', ["ф"]='f', ["Х"]='H', ["х"]='h', ["Ц"]='C', ["ц"]='c', ["Ч"]='Č', ["ч"]='č', ["Ш"]='Š', ["ш"]='š', 
	["Щ"]='Št', ["щ"]='št', ["Ъ"]='Ǎ', ["ъ"]='ǎ', ["Ю"]='Ju', ["ю"]='ju', ["Я"]='Ja', ["я"]='ja',
	["ѝ"]='ì',
 
	-- Pre-reform
	["Ѫ"]='Ǫ', ["ѫ"]='ǫ', ["Ѣ"]='Ě', ["ѣ"]='ě', ["Ь"]='ʹ', ["ь"]='ʹ',
};
 
function export.tr(text, lang, sc)
	text = mw.ustring.gsub(text, '(%w)[Ъъ]$', '%1')
	text = mw.ustring.gsub(text, '(%w)[Ъъ]%f[%c%p%s]', '%1')
	text = mw.ustring.gsub(text, '[Ьь]%f[Оо]', { ["Ь"]='J', ["ь"]='j' })
	text = mw.ustring.gsub(text, '.', tt)
	return text
end
 
return export