Modul:Glag-translit
Napohlad
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate text in the Glagolitic script. It is used to transliterate starocyrkwinosłowjanšćina, 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.
Functions
[wobdźěłać]tr(text, lang, sc)- Transliterates a given piece of
textwritten 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 = {}
letters["Glag"] = {
["Ⰰ"]='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',
["Ⱍ"]='Č', ["ⱍ"]='č',
["Ⱎ"]='Š', ["ⱎ"]='š',
-- For Ⱋ see below
["Ⱏ"]='Ŭ', ["ⱏ"]='ŭ',
["Ⱐ"]='Ĭ', ["ⱐ"]='ĭ', ["Ⱜ"]='Ĭ', ["ⱜ"]='ĭ',
["Ⱑ"]='Ě', ["ⱑ"]='ě',
["Ⱓ"]='Ju', ["ⱓ"]='ju',
["Ⱔ"]='Ę', ["ⱔ"]='ę',
["Ⱕ"]='Y̨', ["ⱕ"]='y̨',
["Ⱗ"]='Ję', ["ⱗ"]='ję',
["Ⱘ"]='Ǫ', ["ⱘ"]='ǫ', ["Ⱖ"]='Ǫ', ["ⱖ"]='ǫ',
["Ⱙ"]='Jǫ', ["ⱙ"]='jǫ',
["Ⱚ"]='Θ', ["ⱚ"]='θ',
["Ⱛ"]='Ü', ["ⱛ"]='ü',
}
digraphs["Glag"] = {
["Ⱏ[ⰉⰊⰋⰹⰺⰻ]"]="Y", ["ⱏ[ⰹⰺⰻ]"]="y",
}
function export.tr(text, lang, sc)
if not sc then
sc = require("Modul:languages").getByCode(lang):findBestScript(text):getCode()
end
-- Щ was pronounced differently in Old Church Slavonic
if lang == "cu" then
letters["Glag"]["Ⱋ"]='Št'
letters["Glag"]["ⱋ"]='št'
else
letters["Glag"]["Ⱋ"]='Šč'
letters["Glag"]["ⱋ"]='šč'
end
-- Transliterate the titlo as colon
text = string.gsub(text, mw.ustring.char(0x0483), ":")
if sc == "Glag" 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