Modul:Cyrs-Glag-translit

This module is used to transliterate text in the Old Cyrillic and Glagolitic alphabets. It is used for Old Church Slavonic and Old East Slavic terms.

Call it so:

 {{#invoke:Cyrs-Glag-translit|tr|(term)|(language code)|(Cyrs or Glag)}}

The language code is necessary because some letters are transliterated slightly differently depending on the language. The script code selects between Cyrillic and Glagolitic transliteration.


local export = {}
 
local letters = {}
local digraphs = {}
 
letters["Cyrs"] = {
    ["А"]='A', ["а"]='a',
    ["Б"]='B', ["б"]='b',
    ["В"]='V', ["в"]='v',
    ["Г"]='G', ["г"]='g', 
    ["Д"]='D', ["д"]='d',
    ["Е"]='E', ["е"]='e', ["Є"]='E', ["є"]='e', 
    ["Ж"]='Ž', ["ж"]='ž',
    ["Ѕ"]='Dz', ["ѕ"]='dz', ["Ꙃ"]='Dz', ["ꙃ"]='dz',
    ["З"]='Z', ["з"]='z', ["Ꙁ"]='Z', ["ꙁ"]='z',
    ["И"]='I', ["и"]='i', ["І"]='I', ["і"]='i', ["Ї"]='I', ["ї"]='i',
    ["К"]='K', ["к"]='k',
    ["Л"]='L', ["л"]='l', 
    ["М"]='M', ["м"]='m',
    ["Н"]='N', ["н"]='n',
    ["О"]='O', ["о"]='o', ["Ѡ"]='O', ["ѡ"]='o',
    ["П"]='P', ["п"]='p', 
    ["Р"]='R', ["р"]='r',
    ["С"]='S', ["с"]='s',
    ["Т"]='T', ["т"]='t',
    ["Ѹ"]='U', ["ѹ"]='u', ["Ꙋ"]='U', ["ꙋ"]='u', ["У"]='U', ["у"]='u',
    ["Ф"]='F', ["ф"]='f',
    ["Х"]='X', ["х"]='x',
 
    ["Ц"]='C', ["ц"]='c',
    ["Ч"]='Č', ["ч"]='č', 
    ["Ш"]='Š', ["ш"]='š',
    -- For Щ see below
    ["Ъ"]='Ŭ', ["ъ"]='ŭ',
    ["Ꙑ"]='Y', ["ꙑ"]='y', ["Ы"]='Y', ["ы"]='y',
    ["Ь"]='Ĭ', ["ь"]='ĭ',
    ["Ѣ"]='Ě', ["ѣ"]='ě',
 
    ["Ю"]='Ju', ["ю"]='ju', 
    ["Ꙗ"]='Ja', ["ꙗ"]='ja',
    ["Ѥ"]='Je', ["ѥ"]='je',
    ["Ѧ"]='Ę', ["ѧ"]='ę',
    ["Ѩ"]='Ję', ["ѩ"]='ję',
    ["Ѫ"]='Ǫ', ["ѫ"]='ǫ',
    ["Ѭ"]='Jǫ', ["ѭ"]='jǫ',
 
    ["Ѯ"]='Ks', ["ѯ"]='ks',
    ["Ѱ"]='Ps', ["ѱ"]='ps',
    ["Ѳ"]='Θ', ["ѳ"]='θ',
    ["Ѵ"]='Ü', ["ѵ"]='ü',
}
 
digraphs["Cyrs"] = {
    ["О[Уу]"]="U", ["оу"]="u",
}
 
letters["Glag"] = {
    ["Ⰰ"]='A', ["ⰰ"]='a',
    ["Ⰱ"]='B', ["ⰱ"]='b',
    ["Ⰲ"]='V', ["ⰲ"]='v',
    ["Ⰳ"]='G', ["ⰳ"]='g', 
    ["Ⰴ"]='D', ["ⰴ"]='d',
    ["Ⰵ"]='E', ["ⰵ"]='e',
    ["Ⰶ"]='Ž', ["ⰶ"]='ž',
    ["Ⰷ"]='Dz', ["ⰷ"]='dz',
    ["Ⰸ"]='Z', ["ⰸ"]='z',
    ["Ⰹ"]='I', ["ⰹ"]='i', ["Ⰺ"]='I', ["ⰺ"]='i', ["Ⰻ"]='I', ["ⰻ"]='i',
    ["Ⰽ"]='K', ["ⰽ"]='k',
    ["Ⰾ"]='L', ["ⰾ"]='l', 
    ["Ⰿ"]='M', ["ⰿ"]='m',
    ["Ⱀ"]='N', ["ⱀ"]='n',
    ["Ⱁ"]='O', ["ⱁ"]='o', ["Ⱉ"]='O', ["ⱉ"]='o',
    ["Ⱂ"]='P', ["ⱂ"]='p', 
    ["Ⱃ"]='R', ["ⱃ"]='r',
    ["Ⱄ"]='S', ["ⱄ"]='s',
    ["Ⱅ"]='T', ["ⱅ"]='t',
    ["Ⱆ"]='U', ["ⱆ"]='u', 
    ["Ⱇ"]='F', ["ⱇ"]='f',
    ["Ⱈ"]='X', ["ⱈ"]='x',
 
    ["Ⱌ"]='C', ["ⱌ"]='c',
    ["Ⱍ"]='Č', ["ⱍ"]='č', 
    ["Ⱎ"]='Š', ["ⱎ"]='š',
    -- For Ⱋ see below
    ["Ⱏ"]='Ŭ', ["ⱏ"]='ŭ',
    ["Ⱐ"]='Ĭ', ["ⱐ"]='ĭ',
    ["Ⱑ"]='Ě', ["ⱑ"]='ě',
 
    ["Ⱓ"]='Ju', ["ⱓ"]='ju', 
    ["Ⱔ"]='Ę', ["ⱔ"]='ę',
    ["Ⱗ"]='Ję', ["ⱗ"]='ję',
    ["Ⱘ"]='Ǫ', ["ⱘ"]='ǫ',
    ["Ⱙ"]='Jǫ', ["ⱙ"]='jǫ',
 
    ["Ⱚ"]='Θ', ["ⱚ"]='θ',
    ["Ⱛ"]='Ü', ["ⱛ"]='ü',
}
 
digraphs["Glag"] = {
    ["Ⱏ[ⰉⰊⰹⰺ]"]="Y", ["ⱏ[ⰹⰺ]"]="y",
}
 
function export.tr(text, lang, sc)
    if type(text) == "table" then
        local frame = text
        text = frame.args[1]
        lang = frame.args[2]
        sc   = frame.args[3]
    end
 
    -- Щ was pronounced differently in Old East Slavic
    if lang == "orv" then
        letters["Cyrs"]["Щ"]='Šč'
        letters["Cyrs"]["щ"]='šč'
        letters["Glag"]["Ⱋ"]='Šč'
        letters["Glag"]["ⱋ"]='šč'
    else
        letters["Cyrs"]["Щ"]='Št'
        letters["Cyrs"]["щ"]='št'
        letters["Glag"]["Ⱋ"]='Št'
        letters["Glag"]["ⱋ"]='št'
    end
 
    -- Transliterate the kamora as '
    text = mw.ustring.gsub(text, "҄", "'")
 
    if sc == "Cyrs" or sc == "Glag" then
        for key, repl in pairs(digraphs[sc]) do
            text = mw.ustring.gsub(text, key, repl)
        end
 
        for key, repl in pairs(letters[sc]) do
            text = mw.ustring.gsub(text, key, repl)
        end
    else
        error("This module can only transliterate Old Cyrillic and Glagolitic.")
    end
 
    return text
end
 
return export