Module:Cyrs-translit
Jump to navigation
Jump to search
- The following documentation is located at Module:Cyrs-translit/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate text in the Old Cyrillic script. It is used to transliterate Old Church Slavonic, Old East Slavic, and Old Novgorodian.
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:Cyrs-translit/testcases.
Functions
tr(text, lang, sc)
- Transliterates a given piece of
text
written in the script specified by the codesc
, and language specified by the codelang
. - When the transliteration fails, returns
nil
.
local export = {}
local letters = {}
local digraphs = {}
local double_grave = mw.ustring.char(0x30F)
letters["Cyrs"] = {
["А"]='A', ["а"]='a',
["Б"]='B', ["б"]='b',
["В"]='V', ["в"]='v',
["Г"]='G', ["г"]='g',
["Д"]='D', ["д"]='d',
["Е"]='E', ["е"]='e', ["Є"]='E', ["є"]='e',
["Ж"]='Ž', ["ж"]='ž',
["Ѕ"]='Dz', ["ѕ"]='dz', ["Ꙃ"]='Dz', ["ꙃ"]='dz', ["Ꙅ"]='Dz', ["ꙅ"]='dz',
["З"]='Z', ["з"]='z', ["Ꙁ"]='Z', ["ꙁ"]='z',
["И"]='I', ["и"]='i', ["І"]='I', ["і"]='i', ["Ї"]='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', ["Ѻ"]='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',
["Ѧ"]='Ę', ["ѧ"]='ę', ["Ꙙ"]='Ę', ["ꙙ"]='ę',
["Ѩ"]='Ję', ["ѩ"]='ję', ["Ꙝ"]='Ję', ["ꙝ"]='ję',
["Ѫ"]='Ǫ', ["ѫ"]='ǫ',
["Ѭ"]='Jǫ', ["ѭ"]='jǫ',
["Ꙓ"]='Jě', ["ꙓ"]='jě',
["Ѯ"]='Ks', ["ѯ"]='ks',
["Ѱ"]='Ps', ["ѱ"]='ps',
["Ѳ"]='Θ', ["ѳ"]='θ',
["Ѵ"]='Ü', ["ѵ"]='ü', ["Ѷ"]='Ü' .. double_grave, ["ѷ"]='ü' .. double_grave,
["Ҁ"]='Q', ["ҁ"]='q',
-- newer letters
["Й"]='J', ["й"]='j', -- starting from 15th century
["Ґ"]='G', ["ґ"]='g',
["Э"]='E', ["э"]='e',
}
digraphs["Cyrs"] = {
["([АаꙖꙗ])ѵ"]="%1v",
["([АаꙖꙗ])Ѵ"]="%1V",
["О[УѴуѵ]"]="U", ["о[уѵ]"]="u",
["Ъ[Ии]"]="Y", ["ъи"]="y",
["([аеїиоуѡъыьѣєюꙗѧіꙋѫѵяэѻꙍѽꙑꙓѥѩѭѷАЕЇИОУѠЪЫЬѢЄЮꙖѦІꙊѪѴЯЭѺꙌѼꙐꙒѤѨѬѶ])е"]="%1je",
["([аеїиоуѡъыьѣєюꙗѧіꙋѫѵяэѻꙍѽꙑꙓѥѩѭѷАЕЇИОУѠЪЫЬѢЄЮꙖѦІꙊѪѴЯЭѺꙌѼꙐꙒѤѨѬѶ])ѣ"]="%1jě",
["([аеїиоуѡъыьѣєюꙗѧіꙋѫѵяэѻꙍѽꙑꙓѥѩѭѷАЕЇИОУѠЪЫЬѢЄЮꙖѦІꙊѪѴЯЭѺꙌѼꙐꙒѤѨѬѶ])ѧ"]="%1ję",
["Ѿ([аеїиоуѡъыьѣєюꙗѧіꙋѫѵяэѻꙍѽꙑꙓѥѩѭѷбвгджѕꙃꙅзꙁꙉклмнпрстфхцчшѯѱѳҁ])"]="Ot%1",
["ѿ([аеїиоуѡъыьѣєюꙗѧіꙋѫѵяэѻꙍѽꙑꙓѥѩѭѷбвгджѕꙃꙅзꙁꙉклмнпрстфхцчшѯѱѳҁ])"]="ot%1",
}
function export.tr(text, lang, sc)
if not sc then
sc = require("Module:languages").getByCode(lang):findBestScript(text):getCode()
end
-- Щ was pronounced differently in Old Church Slavonic
if lang == "cu" then
letters["Cyrs"]["Щ"]='Št'
letters["Cyrs"]["щ"]='št'
else
letters["Cyrs"]["Щ"]='Šč'
letters["Cyrs"]["щ"]='šč'
end
-- Ѿ was pronounced differently in Old Novgorodian
if lang == "zle-ono" then
letters["Cyrs"]["Ѿ"]='Otŭ'
letters["Cyrs"]["ѿ"]='otŭ'
else
letters["Cyrs"]["Ѿ"]='Otŭ'
letters["Cyrs"]["ѿ"]='otŭ'
end
-- Transliterate the kamora as prime
text = string.gsub(text, "\210\132", "ʹ")
-- Transliterate the titlo as colon
text = string.gsub(text, mw.ustring.char(0x0483), ":")
if sc == "Cyrs" then
for key, repl in pairs(digraphs[sc]) do
text = mw.ustring.gsub(text, key, repl)
end
-- pattern for one non-ASCII character
text = string.gsub(text, '[\194-\244][\128-\191]+', letters[sc])
end
return text
end
return export