Модул:be-translit
Изглед
Документацију овог модула можете да направите на страници Модул:be-translit/док
local export = {}
local acute = mw.ustring.char(0x301)
local tt = {
["А"]='A', ["а"]='a', ["Б"]='B', ["б"]='b', ["В"]='V', ["в"]='v', ["Г"]='H', ["г"]='h', ["Д"]='D', ["д"]='d',
["Е"]='Je', ["е"]='je', ["Ё"]='Jo', ["ё"]='jo', ["Ж"]='Ž', ["ж"]='ž', ["З"]='Z', ["з"]='z', ["І"]='I', ["і"]='i',
["И"]='I', ["и"]='i', -- present for Old Belarusian; FIXME, remove when we have a separate language code for this lang
["Й"]='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',
["’"]='ʺ', ["ʼ"]='ʺ',
-- currently non-standard, used in some older norms
["Ґ"]='G', ["ґ"]='g'
};
local unstressed_vowels = "aeiyuAEIYU"
local unstressed_vowel = "[" .. unstressed_vowels .. "]"
function export.tr(text, lang, sc)
text = mw.ustring.gsub(text, "'+", { ["'"] = 'ʺ' }) -- neutral apostrophe
text = mw.ustring.gsub(text, '.', tt)
-- Mark word boundaries
text = mw.ustring.gsub(text, "(%s+)", "#%1#")
text = "#" .. text .. "#"
-- Mark stress on <o>
text = mw.ustring.gsub(text, "(#[^#Oo" .. acute .. "]*)([Oo])([^#Oo" .. acute .. "]*" .. unstressed_vowel .. "[^#Oo" .. acute .. "]*#)", "%1%2" .. acute .. "%3")
text = mw.ustring.gsub(text, "(#[^#Oo" .. acute .. "]*" .. unstressed_vowel .. "[^#Oo" .. acute .. "]*)([Oo])([^#Oo" .. acute .. "]*#)", "%1%2" .. acute .. "%3")
--Strip hashes
text = mw.ustring.gsub(text, "#", "")
return text
end
return export