Module:el-translit-2
Documentation for this module may be created at Module:el-translit-2/τεκμηρίωση
-- = ΕΛΟΤ 743-2 χωρίς διακριτικά
local p = {}
local tt = {
["α"] = "a", ["ά"] = "a", ["β"] = "v", ["γ"] = "g", ["δ"] = "d",
["ε"] = "e", ["ζ"] = "z", ["η"] = "i", ["ή"] = "i", ["θ"] = "th",
["ι"] = "i", ["ί"] = "i", ["ϊ"] = "i", ["ΐ"] = "i", ["κ"] = "k", ["λ"] = "l", ["μ"] = "m",
["ν"] = "n", ["ξ"] = "x", ["ο"] = "o", ["ό"] = "o", ["π"] = "p",
["ρ"] = "r", ["σ"] = "s", ["ς"] = "s",
["τ"] = "t", ["υ"] = "y", ["ύ"] = "y", ["ϋ"] = "y", ["ΰ"] = "y", ["φ"] = "f",
["χ"] = "ch", ["ψ"] = "ps", ["ω"] = "o", ["ώ"] = "o",
["Α"] = "A", ["Β"] = "V", ["Γ"] = "G", ["Δ"] = "D",
["Ε"] = "E", ["Ζ"] = "Z", ["Η"] = "I", ["Ή"] = "I", ["Θ"] = "Th",
["Ι"] = "I", ["Í"] = "I", ["Ï"] = "I", ["Κ"] = "K", ["Λ"] = "L", ["Μ"] = "M",
["Ν"] = "N", ["Ξ"] = "X", ["Ο"] = "O", ["Ό"] = "O", ["Π"] = "P",
["Ρ"] = "R", ["Σ"] = "S",
["Τ"] = "T", ["Υ"] = "Y", ["Ύ"] = "Y", ["Ϋ"] = "Y", ["Φ"] = "F",
["Χ"] = "Ch", ["Ψ"] = "Ps", ["Ω"] = "O", ["Ώ"] = "O",
[";"] = "?", ["·"] = ";"
}
-- transliterates any words or phrases
function p.tr(text)
if type(text) == "table" then text = text.args[1] end
local gsub = mw.ustring.gsub
local find = mw.ustring.find
local acute = mw.ustring.char(0x301)
local diaeresis = mw.ustring.char(0x308)
local vowels = "[αΑεΕηΗιΙυΥοΟωΩ" .. acute .. diaeresis .. "]"
text = mw.text.trim(text)
text = mw.ustring.toNFD(text)
text = mw.ustring.gsub(text, acute .. diaeresis, diaeresis .. acute)
text = gsub(text, "([αΑεΕηΗ])υ(.?)",
function (vowel, following)
if following == diaeresis then
return tt[vowel] .. "y"
end
if following == " " or following == "" then -- αυ > af στο τέλος λέξης
return tt[vowel] .. "f" .. following
end
if find(following, "[βγδζλμνρΒΓΔΖΛΜΝΡαεηιυοωΑΕΗΙΥΟΩ]") then -- αυ > av (αν ακολουθεί β, γ, δ, ζ, λ, μ, ν, ρ, φωνήεν)
return tt[vowel] .. "v" .. following
end
if find(following, "[θκξπστφχψΘΚΞΠΣΤΦΧΨ]") then -- αυ > af (αν ακολουθεί θ, κ, ξ, π, σ, τ, φ, χ, ψ)
return tt[vowel] .. "f" .. following
end
end)
text = gsub(text, "([οΟ])υ", {["ο"] = "ou", ["Ο"] = "Ou"})
-- αφαίρεση τόνων και διαλυτικών
text = gsub(text, diaeresis, "")
text = gsub(text, acute, "")
text = gsub(text, "(γ)(γ)", "ng")
text = gsub(text, "(Γ)(Γ)", "NG")
text = gsub(text, "(γ)(ξ)", "nx")
text = gsub(text, "(Γ)(Ξ)", "NX")
text = gsub(text, "(γ)(χ)", "nch")
text = gsub(text, "(Γ)(Χ)", "NCH")
text = gsub(text, "(.?)[μ][π](.?)",
function (before, following)
if before == "" or before == " " or before == "-" or following == "" or following == " " or following == "-" then
return before .. "b" .. following else return before .. "mp" .. following
end
end)
text = gsub(text, "(.?)[Μ][Π](.?)",
function (before, following)
if before == "" or before == " " or before == "-" or following == "" or following == " " or following == "-" then
return before .. "B" .. following else return before .. "MP" .. following
end
end)
text = gsub(text, "Μπ", "B")
text = gsub(text, ".", tt)
return text
end
return p