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', ["Ѿ"]='Otŭ', ["ѿ"]='otŭ', ["Ꙩ"]='O', ["ꙩ"]='o', ["Ꙫ"]='O', ["ꙫ"]='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', ["Я"]='Ja', ["я"]='ja',
["Ѥ"]='Je', ["ѥ"]='je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ⱍ"]='č',
["Ⱎ"]='Š', ["ⱎ"]='š',
-- For Ⱋ see below
["Ⱏ"]='Ŭ', ["ⱏ"]='ŭ',
["Ⱐ"]='Ĭ', ["ⱐ"]='ĭ',
["Ⱑ"]='Ě', ["ⱑ"]='ě',
["Ⱓ"]='Ju', ["ⱓ"]='ju',
["Ⱔ"]='Ę', ["ⱔ"]='ę',
["Ⱗ"]='Ję', ["ⱗ"]='ję',
["Ⱘ"]='Ǫ', ["ⱘ"]='ǫ',
["Ⱙ"]='Jǫ', ["ⱙ"]='jǫ',
["Ⱚ"]='Θ', ["ⱚ"]='θ',
["Ⱛ"]='Ü', ["ⱛ"]='ü',
}
digraphs["Glag"] = {
["Ⱏ[ⰉⰊⰹⰺ]"]="Y", ["ⱏ[ⰹⰺ]"]="y",
}
function export.tr(text, lang, sc)
if not sc then sc = require("Module:scripts").findBestScript(text, require("Module:languages").getByCode(lang)):getCode() 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 prime
text = mw.ustring.gsub(text, "\210\132", "ʹ")
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 (Cyrs) and Glagolitic (Glag).")
end
return text
end
return export