Modul:Umschrift
Erscheinungsbild
Die Dokumentation für dieses Modul kann unter Modul:Umschrift/Doku erstellt werden
-- Stand 5. August 2024, 17:12 Quelle nur für "function Umschrift.agrDIN(str)" in der Quelle "function Umschrift.grc(str)" siehe https://de.wiktionary.org/wiki/Modul:Umschrift
-- Erzeugt die lateinische Umschrift eines Textes in altgriechische Schriftart in den Funktionen nach DIN 31634:2011-10 agr.DIN, demgemäß Zahlen nach agrZZ, englischem Wiktonary agrEIN
-- Ein weiteres Modul zur Umschrift ist Modul:Umschriftung mit Lua-Tabelle Modul:Umschriftung/agrie.
local Umschrift = {}
function Umschrift.main(frame)
Sprachkuerzel = frame.args.spr
if (Sprachkuerzel == "ab") then
return Umschrift.ab(frame.args[1])
elseif (Sprachkuerzel == "agrDIN") then
return Umschrift.agrDIN(frame.args[1])
elseif (Sprachkuerzel == "agrEIN") then
return Umschrift.agrEIN(frame.args[1])
end
end
-- Erzeugt die lateinische Umschrift eines Textes in altgriechischer Schrift
-- gemäß DIN 31634 (siehe auch Wikipedia:Griechisches Alphabet)
function Umschrift.agrDIN(str)
local newstr = ""
local newcp = 0
local cp = 1
local grb = "βΒδΔγΓϊΪκΚλΛμΜνΝπϖΠρῤϱΡσςΣτΤϋΫξΞζΖ;·Ϝϝ"
local lat = "bBdDgGïÏkKlLmMnNppPrrrRssStTÿŸxXzZ?;Ww"
local element = ""
local strlen = mw.ustring.len(str)
local j = 0
local Kat = ""
local possible2 = "y"
local first = ""
local second = ""
local endgef = 0
local Blank = "%s" -- whitespace
local blgef = 0
local pgef = 0
while cp <= strlen do
-- Blank und Interpunktionen abarbeiten
first = mw.ustring.sub(str, cp, cp)
while (cp <= strlen and (first == " " or mw.ustring.find(first, "%p", 1))) do
if first == ";" then
newstr = newstr .. "?"
elseif first == "·" then
newstr = newstr .. ";"
else
newstr = newstr .. first
end
cp = cp + 1
first = mw.ustring.sub(str, cp, cp)
end
-- Zahlschrift überprüfen
if cp <= strlen - 1 then
blgef = mw.ustring.find(mw.ustring.sub(str, cp, strlen), Blank, 1)
pgef = mw.ustring.find(mw.ustring.sub(str, cp, strlen), "%p", 1)
endgef = strlen + 1
if (blgef) then endgef = cp + blgef - 1 end
if (pgef) then
if pgef < endgef then endgef = cp + pgef - 1 end
end
local cpend = endgef - 1
if (mw.ustring.sub(str, cpend, cpend) == "ʹ" or
mw.ustring.sub(str, cp, cp) == "͵") then
-- Zahlschrift ermitteln
newstr = newstr .. Umschrift.grcZZ(mw.ustring.sub(str, cp, cpend))
cp = endgef
end
end
-- zweistellige Buchstabenkominationen
if (cp + 1 <= strlen and possible2 == "y") then
element = (mw.ustring.sub(str, cp, cp+1))
first = (mw.ustring.sub(str, cp, cp))
second = (mw.ustring.sub(str, cp+1, cp+1))
if (first == "α" and mw.ustring.find("υύὺῠῡὐὔὒῦὖ", second, 1, true)) then
newstr = newstr .. "au"
cp = cp + 2
elseif (first == "Α" and mw.ustring.find("υύὺῠῡὐὔὒῦὖ", second, 1, true)) then
newstr = newstr .. "Au"
cp = cp + 2
elseif (element == "αϋ") then
newstr = newstr .. "aÿ"
cp = cp + 2
elseif (element == "Αϋ") then
newstr = newstr .. "Aÿ"
cp = cp + 2
elseif (first == "α" and mw.ustring.find("ἱἵἳἷ", second, 1, true)) then
newstr = newstr .. "hai"
cp = cp + 2
elseif (first == "Α" and mw.ustring.find("ἱἵἳἷ", second, 1, true)) then
newstr = newstr .. "Hai"
cp = cp + 2
elseif (first == "ε" and mw.ustring.find("ἱἵἳἷ", second, 1, true)) then
newstr = newstr .. "hei"
cp = cp + 2
elseif (first == "Ε" and mw.ustring.find("ἱἵἳἷ", second, 1, true)) then
newstr = newstr .. "Hei"
cp = cp + 2
elseif (first == "ε" and mw.ustring.find("ὑὕὓὗ", second, 1, true)) then
newstr = newstr .. "heu"
cp = cp + 2
elseif (first == "Ε" and mw.ustring.find("ὑὕὓὗ", second, 1, true)) then
newstr = newstr .. "Heu"
cp = cp + 2
elseif (first == "ε" and mw.ustring.find("υύὺῠῡὐὔὒῦὖ", second, 1, true)) then
newstr = newstr .. "eu"
cp = cp + 2
elseif (first == "Ε" and mw.ustring.find("υύὺῠῡὐὔὒῦὖ", second, 1, true)) then
newstr = newstr .. "Eu"
cp = cp + 2
elseif (element == "ηυ") then
newstr = newstr .. "ēu"
cp = cp + 2
elseif (element == "Ηυ") then
newstr = newstr .. "Ēu"
cp = cp + 2
elseif (element == "γγ") then
newstr = newstr .. "ng"
cp = cp + 2
elseif (element == "Γγ") then
newstr = newstr .. "Ng"
cp = cp + 2
elseif (element == "γκ") then
if (cp == 1 or (cp > 1 and mw.ustring.sub(str, cp-1, cp-1) == " ")) then
newstr = newstr .. "gk"
else
newstr = newstr .. "nk"
end
cp = cp + 2
elseif (element == "Γk") then
if (cp == 1 or (cp > 1 and mw.ustring.sub(str, cp-1, cp-1) == " ")) then
newstr = newstr .. "Gk"
else
newstr = newstr .. "Nk"
end
cp = cp + 2
elseif (element == "γξ") then
newstr = newstr .. "nx"
cp = cp + 2
elseif (element == "Γξ") then
newstr = newstr .. "Nx"
cp = cp + 2
elseif (element == "γχ") then
newstr = newstr .. "nch"
cp = cp + 2
elseif (element == "Γχ") then
newstr = newstr .. "Nch"
cp = cp + 2
elseif (element == "ηυ") then
newstr = newstr .. "ēu"
cp = cp + 2
elseif (element == "Ηυ") then
newstr = newstr .. "Ēu"
cp = cp + 2
elseif (first == "η" and mw.ustring.find("ὑὕὓὗ", second, 1, true)) then
newstr = newstr .. "hēu"
cp = cp + 2
elseif (first == "Η" and mw.ustring.find("ὑὕὓὗ", second, 1, true)) then
newstr = newstr .. "Hēu"
cp = cp + 2
elseif (first == "ο" and mw.ustring.find("ἱἵἳἷ", second, 1, true)) then
newstr = newstr .. "hoi"
cp = cp + 2
elseif (first == "Ο" and mw.ustring.find("ἱἵἳἷ", second, 1, true)) then
newstr = newstr .. "Hoi"
cp = cp + 2
elseif (first == "ο" and mw.ustring.find("ὑὕὓὗ", second, 1, true)) then
newstr = newstr .. "hu"
cp = cp + 2
elseif (first == "Ο" and mw.ustring.find("ὑὕὓὗ", second, 1, true)) then
newstr = newstr .. "Hu"
cp = cp + 2
elseif (first == "ο" and mw.ustring.find("υύὺῠῡὐὔὒῦὖ", second, 1, true)) then
newstr = newstr .. "u"
cp = cp + 2
elseif (first == "Ο" and mw.ustring.find("υύὺῠῡὐὔὒῦὖ", second, 1, true)) then
newstr = newstr .. "U"
cp = cp + 2
elseif (first == "υ" and mw.ustring.find("ἱἵἳἷ", second, 1, true)) then
newstr = newstr .. "hyi"
cp = cp + 2
elseif (first == "Υ" and mw.ustring.find("ἱἵἳἷ", second, 1, true)) then
newstr = newstr .. "Hyi"
cp = cp + 2
elseif (element == "ῤῥ") then
newstr = newstr .. "rrh"
cp = cp + 2
else
possible2 = "n"
end
elseif (cp <= strlen) then
-- einzelne Buchstaben
local h_erwartet = ""
element = mw.ustring.sub(str, cp, cp)
if (cp == 1) then
h_erwartet = "j"
else
local zuvor = mw.ustring.sub(str, cp-1, cp-1)
if (zuvor == " " or mw.ustring.find(zuvor, "%p", 1)) then
h_erwartet = "j"
end
end
if (element == "θ" or element == "ϑ") then
newstr = newstr .. "th"
elseif (element == "Θ" or element == "ϴ") then
newstr = newstr .. "Th"
elseif (mw.ustring.find("αάὰᾰᾱᾷἀἄἂᾆᾶᾳᾴᾲἆᾀᾄᾂ", element, 1, true)) then
newstr = newstr .. "a"
elseif (mw.ustring.find("ΑΆᾺᾸᾹἈἌἊᾎᾼἎᾈᾌᾊ", element, 1, true)) then
newstr = newstr .. "A"
elseif (mw.ustring.find("εέὲἐἔἒ", element, 1, true)) then
newstr = newstr .. "e"
elseif (mw.ustring.find("ΕΈῈἘἜἚ", element, 1, true)) then
newstr = newstr .. "E"
elseif (mw.ustring.find("ηήὴῇἠἤἢᾖῆῃῄῂἦᾐᾔᾒ", element, 1, true)) then
newstr = newstr .. "ē"
elseif (mw.ustring.find("ΗΉῊἨἬἪᾞῌἮᾘᾜᾚ", element, 1, true)) then
newstr = newstr .. "Ē"
elseif (mw.ustring.find("ἁἅἃᾇἇᾁᾅᾃ", element, 1, true)) then
if (h_erwartet ~= "") then
newstr = newstr .. "ha"
else
newstr = newstr .. "a"
end
elseif (mw.ustring.find("ἉἍἋᾏἏᾉᾍᾋ", element, 1, true)) then
if (h_erwartet ~= "") then
newstr = newstr .. "Ha"
else
newstr = newstr .. "A"
end
elseif (mw.ustring.find("ἑἕἓ", element, 1, true)) then
if (h_erwartet ~= "") then
newstr = newstr .. "he"
else
newstr = newstr .. "e"
end
elseif (mw.ustring.find("ἙἝἛ", element, 1, true)) then
if (h_erwartet ~= "") then
newstr = newstr .. "He"
else
newstr = newstr .. "E"
end
elseif (mw.ustring.find("ἡἥἣᾗἧᾑᾕᾓ", element, 1, true)) then
if (h_erwartet ~= "") then
newstr = newstr .. "hē"
else
newstr = newstr .. "ē"
end
elseif (mw.ustring.find("ἩἭἫᾟἯᾙᾝᾛ", element, 1, true)) then
if (h_erwartet ~= "") then
newstr = newstr .. "Hē"
else
newstr = newstr .. "Ē"
end
elseif (mw.ustring.find("ἱἵἳἷ", element, 1, true)) then
if (h_erwartet ~= "") then
newstr = newstr .. "hi"
else
newstr = newstr .. "i"
end
elseif (mw.ustring.find("ἹἽἻἿ", element, 1, true)) then
if (h_erwartet ~= "") then
newstr = newstr .. "Hi"
else
newstr = newstr .. "I"
end
elseif (mw.ustring.find("ὁὅὃ", element, 1, true)) then
if (h_erwartet ~= "") then
newstr = newstr .. "ho"
else
newstr = newstr .. "o"
end
elseif (mw.ustring.find("ὉὍὋ", element, 1, true)) then
if (h_erwartet ~= "") then
newstr = newstr .. "Ho"
else
newstr = newstr .. "O"
end
elseif (mw.ustring.find("ὡὥὣᾧὧᾡᾥᾣ", element, 1, true)) then
if (h_erwartet ~= "") then
newstr = newstr .. "hō"
else
newstr = newstr .. "ō"
end
elseif (mw.ustring.find("ὩὭὫᾯὯᾩᾭᾫ", element, 1, true)) then
if (h_erwartet ~= "") then
newstr = newstr .. "Hō"
else
newstr = newstr .. "Ō"
end
elseif (mw.ustring.find("ὑὕὓὗ", element, 1, true)) then
if (h_erwartet ~= "") then
newstr = newstr .. "hy"
else
newstr = newstr .. "y"
end
elseif (mw.ustring.find("ὙὝὛὟ", element, 1, true)) then
if (cp == 1) then
newstr = newstr .. "Hy"
else
newstr = newstr .. "Y"
end
elseif (mw.ustring.find("ιίὶῐῑἰἴἲῖἶ", element, 1, true)) then
newstr = newstr .. "i"
elseif (mw.ustring.find("ΙΊῚῘῙἸἼἺἾ", element, 1, true)) then
newstr = newstr .. "I"
elseif (mw.ustring.find("ΐῒῗ", element, 1, true)) then
newstr = newstr .. "ï"
elseif (mw.ustring.find("οόὸὀὄὂ", element, 1, true)) then
newstr = newstr .. "o"
elseif (mw.ustring.find("ΟΌῸὈὌὊ", element, 1, true)) then
newstr = newstr .. "O"
elseif (mw.ustring.find("ωώὼῷὠὤὢᾦῶῳῴὦᾠᾤᾢ", element, 1, true)) then
newstr = newstr .. "ō"
elseif (mw.ustring.find("ΩΏῺὨὬὪᾮῼὮᾨᾬᾪ", element, 1, true)) then
newstr = newstr .. "Ō"
elseif (element == "φ") then
newstr = newstr .. "ph"
elseif (element == "Φ") then
newstr = newstr .. "Ph"
elseif (element == "χ") then
newstr = newstr .. "ch"
elseif (element == "Χ") then
newstr = newstr .. "Ch"
elseif (element == "ψ") then
newstr = newstr .. "ps"
elseif (element == "Ψ") then
newstr = newstr .. "Ps"
elseif (element == "ῥ") then
newstr = newstr .. "rh"
elseif (element == "Ῥ") then
newstr = newstr .. "Rh"
elseif (mw.ustring.find("υύὺῠῡὐὔὒῦὖ", element, 1, true)) then
newstr = newstr .. "y"
elseif (mw.ustring.find("ΥΎῪῨῩ", element, 1, true)) then
newstr = newstr .. "Y"
elseif (mw.ustring.find("ϋΰῢῧ", element, 1, true)) then
newstr = newstr .. "ÿ"
else
newcp = mw.ustring.find(grb, element, 1, true)
if (newcp) then
newstr = newstr .. (mw.ustring.sub(lat, newcp, newcp))
else
j = mw.ustring.find(element, "%a", 1)
if (j and Zeichensatz == "homogen") then
newstr = newstr .. "■"
Kat = "[[Kategorie:Wartung falsche Übersetzungen (Altgriechisch)]]"
else
newstr = newstr .. (mw.ustring.sub(str, cp, cp))
end
end
end
cp = cp + 1
possible2 = "y"
end
end
return newstr .. Kat
end
-- Umschlüsselung altgriechischer Zahlzeichen in arabische Ziffern
function Umschrift.agrZZ(str)
local ZZ = "ΑΒΓΔΕϚΖΗΘΙΚΛΜΝΞΟΠϞΡΣΤΥΦΧΨΩϠ"
local Zahlen = {1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900}
local Suche = ""
local strlen = mw.ustring.len(str)
local mio = 0
local tsd = 0
local ezh = 0 -- Einer, Zehner, Hunderter
local Summe = 0
local Potenz_zuvor = -1
local Potenz = 0
local go_on = true
local endcp = strlen
local Bereich = ""
local index = 0
local cp = strlen
if (mw.ustring.sub(str, cp, cp) == "ʹ") then
cp = cp - 1
while (cp >= 1 and go_on) do
Suche = mw.ustring.upper(mw.ustring.sub(str,cp,cp))
index = mw.ustring.find(ZZ, Suche, 1, true)
if (index == nil) then
if Suche == "Ϙ" then
index = 18
end
end
if (index) then
Potenz = math.floor((index-1)/9)
if Potenz_zuvor < 0 then
ezh = Zahlen [index]
cp = cp - 1
Potenz_zuvor = Potenz
elseif (Potenz > Potenz_zuvor) then
if (cp == 1 or (cp > 1 and mw.ustring.sub(str, cp-1, cp-1) ~= "͵")) then
ezh = ezh + Zahlen [index]
cp = cp - 1
Potenz_zuvor = Potenz
else
go_on = false -- Tausender- oder Million-Kennzeichen
end
else
go_on = false -- vermutlicher Tausender-/Millionen-Wert
end
else
return "Falsches Zahlzeichen: " .. mw.ustring.sub(str,cp,cp)
end
end
endcp = cp -- letztes Zeichen von Millionen oder Tausender
end
if cp >= 1 then
cp = 1
if mw.ustring.sub(str, 1, 1) ~= "͵" then
return "Fehlendes Stellenwertsymbol am Beginn"
end
end
while (cp > 0 and cp <= endcp) do
if (mw.ustring.sub(str, cp, cp+1) == "͵͵" or
(mw.ustring.sub(str, cp, cp) ~= "͵" and Bereich == "M")) then -- Millionen
if (mw.ustring.sub(str, cp, cp+1) == "͵͵") then cp = cp + 2 end
Bereich = "M"
Suche = mw.ustring.upper(mw.ustring.sub(str,cp,cp))
index = mw.ustring.find(ZZ, Suche, 1, true)
if (index == nil) then
if Suche == "Ϙ" then
index = 18
end
end
if (index) then
mio = mio + Zahlen [index]
cp = cp + 1
else
return "Falsches Zahlzeichen: " .. mw.ustring.sub(str,cp,cp)
end
elseif (mw.ustring.sub(str, cp, cp) == "͵" or Bereich == "T") then -- Tausender
if (mw.ustring.sub(str, cp, cp) == "͵") then cp = cp + 1 end
Bereich = "T"
Suche = mw.ustring.upper(mw.ustring.sub(str,cp,cp))
index = mw.ustring.find(ZZ, Suche, 1, true)
if (index == nil) then
if Suche == "Ϙ" then
index = 18
end
end
if (index) then
tsd = tsd + Zahlen [index]
cp = cp + 1
else
return "Falsches Zahlzeichen: " .. mw.ustring.sub(str,cp,cp)
end
end
end
tsd = tsd * 1000
mio = mio * 1000000
Summe = mio + tsd + ezh
Bereich = mw.ustring.format("%d", Summe)
strlen = mw.ustring.len(Bereich)
if strlen > 6 then
return mw.ustring.sub(Bereich, 1, strlen-6) .. "." ..
mw.ustring.sub(Bereich, strlen-5, strlen-3) .. "." ..
mw.ustring.sub(Bereich, strlen-2, strlen)
elseif strlen > 4 then
return mw.ustring.sub(Bereich, 1, strlen-3) .. "." ..
mw.ustring.sub(Bereich, strlen-2, strlen)
else
return Bereich
end
end
-- Rückgabe der Umschrift für agrDIN
-- Hinweis: Doppelte Definitionen vermeiden. agrEIN ist bereits definiert.
-- Ende agrDIN
-- ab hier agrEIN Translitteration
function Umschrift.agrEIN(text)
local ersetzungen_phon = {
["γγ"] = "ng", ["γκ"] = "nk", ["γξ"] = "nx", ["γχ"] = "nch",
["θ"] = "th", ["φ"] = "ph", ["χ"] = "kh",
["α"] = "a", ["β"] = "b", ["γ"] = "g", ["δ"] = "d", ["ε"] = "e",
["ζ"] = "z", ["η"] = "ē", ["ι"] = "i", ["κ"] = "k", ["λ"] = "l",
["μ"] = "m", ["ν"] = "n", ["ξ"] = "x", ["ο"] = "o", ["π"] = "p",
["ρ"] = "r", ["σ"] = "s", ["ς"] = "s", ["τ"] = "t", ["υ"] = "u",
["ω"] = "ō",
["Α"] = "A", ["Β"] = "B", ["Γ"] = "G", ["Δ"] = "D", ["Ε"] = "E",
["Ζ"] = "Z", ["Η"] = "Ē", ["Ι"] = "I", ["Κ"] = "K", ["Λ"] = "L",
["Μ"] = "M", ["Ν"] = "N", ["Ξ"] = "X", ["Ο"] = "O", ["Π"] = "P",
["Ρ"] = "R", ["Σ"] = "S", ["Τ"] = "T", ["Υ"] = "U", ["Φ"] = "Ph",
["Χ"] = "Kh", ["Θ"] = "Th", ["Ω"] = "Ō"
}
local diakritika_phon = {
["ῐ"] = "ĭ", ["ῑ"] = "ī", ["ῠ"] = "ŭ", ["ῡ"] = "ū",
["ά"] = "á", ["έ"] = "é", ["ή"] = "ḗ", ["ί"] = "í",
["ό"] = "ó", ["ύ"] = "ú", ["ώ"] = "ṓ",
["ὰ"] = "à", ["ὲ"] = "è", ["ὴ"] = "è", ["ὶ"] = "ì",
["ὸ"] = "ò", ["ὺ"] = "ù", ["ὼ"] = "ò",
["ᾶ"] = "â", ["ῖ"] = "î", ["ῦ"] = "û", ["ῶ"] = "ô",
["ϊ"] = "ï", ["ϋ"] = "ü", ["ΐ"] = "ḯ", ["ΰ"] = "ǘ",
["Ά"] = "Á", ["Έ"] = "É", ["Ή"] = "Ḗ", ["Ί"] = "Í",
["Ό"] = "Ó", ["Ύ"] = "Ú", ["Ώ"] = "Ṓ"
}
local out = text
for k, v in pairs(diakritika_phon) do
out = mw.ustring.gsub(out, k, v)
end
for k, v in pairs(ersetzungen_phon) do
out = mw.ustring.gsub(out, k, v)
end
return out
end
return Umschrift