Module:be-translit

Definition from Wiktionary, the free dictionary
Jump to: navigation, search
The following documentation is located at Module:be-translit/documentation. [edit]
See also: subpages of this module.

This module will transliterate Belarusian language text per WT:BE 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:be-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', ["Г"]='H', ["г"]='h', ["Д"]='D', ["д"]='d', 
	["Е"]='Je', ["е"]='je', ["Ё"]='Jó', ["ё"]='jó', ["Ж"]='Ž', ["ж"]='ž', ["З"]='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', ["Х"]='X', ["х"]='x', ["Ц"]='C', ["ц"]='c', 
	["Ч"]='Č', ["ч"]='č', ["Ш"]='Š', ["ш"]='š', ["Ы"]='Y', ["ы"]='y', ["Ь"]='ʹ', ["ь"]='ʹ', ["Э"]='E', ["э"]='e', 
	["Ю"]='Ju', ["ю"]='ju', ["Я"]='Ja', ["я"]='ja', 
	["’"]='ʺ', ["ʼ"]='ʺ'
};
 
function export.tr(text, lang, sc)
    text = mw.ustring.gsub(text, "'+", { ["'"] = 'ʺ' }) -- neutral apostrophe
    text = mw.ustring.gsub(text, '.', tt)
 
    return text
end
 
return export