This module will transliterate text in the Glagolitic script. It is used to transliterate Old Church Slavonic, Old Novgorodian, and Church Slavonic.
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:Glag-translit/testcases.
tr(text, lang, sc)
text
written in the script specified by the code sc
, and language specified by the code lang
.nil
.local export = {}
local U = mw.ustring.char
local letters = {
= {
= 'A',
= 'a',
= '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',
= 'M',
= 'm',
= 'N',
= 'n',
= 'O',
= 'o',
= 'O',
= 'o',
= 'P',
= 'p',
= 'R',
= 'r',
= 'S',
= 's',
= 'T',
= 't',
= 'U',
= 'u',
= 'F',
= 'f',
= 'X',
= 'x',
= 'X',
= 'x',
= 'C',
= 'c',
= 'Č',
= 'č',
= 'Š',
= 'š',
= 'Ŭ',
= 'ŭ',
= 'Ĭ',
= 'ĭ',
= 'Ĭ',
= 'ĭ',
= 'Ě',
= 'ě',
= 'Ju',
= 'ju',
= 'Ę',
= 'ę',
= 'Y̨',
= 'y̨',
= 'Ję',
= 'ję',
= 'Ǫ',
= 'ǫ',
= 'Ǫ',
= 'ǫ',
= 'Jǫ',
= 'jǫ',
= 'Θ',
= 'θ',
= 'Ü',
= 'ü',
= 'Št',
= 'št'
},
= {
= 'Ć',
= 'ć',
= 'Ć',
= 'ć',
= 'Ść',
= 'ść'
}
}
local digraphs = {
= {
"] = "Y", "] = "y",
},
= {
"] = 'ŷi',
}
}
function export.tr(text, lang, sc)
if not sc then
sc = require("Module:languages").getByCode(lang):findBestScript(text):getCode()
end
local function digraph_subst(digraphs)
for key, repl in pairs(digraphs) do
text = mw.ustring.gsub(text, key, repl)
end
end
if sc ~= "Glag" then
text = nil
else
-- Transliterate the kamora as prime
text = mw.ustring.gsub(text, U(0x0484), "ʹ")
if digraphs then
digraph_subst(digraphs)
end
digraph_subst(digraphs)
if letters then
text = mw.ustring.gsub(text, '.', letters)
end
text = mw.ustring.gsub(text, '.', letters)
-- Transliterate the titlo and vzmet as colon.
text = mw.ustring.gsub(text, "", ":")
end
return text
end
return export