Module:el-translit: Difference between revisions

Created page with "local m_str_utils = require("Module:string utilities") local gsub = m_str_utils.gsub local sub = m_str_utils.sub local U = m_str_utils.char local acute = U(0x301) local diaeresis = U(0x308) local erotimatiko = U(0x37E) local export = {} local tt = { ["α"] = "a", ["ά"] = "á", ["β"] = "v", ["γ"] = "g", ["δ"] = "d", ["ε"] = "e", ["έ"] = "é", ["ζ"] = "z", ["η"] = "i", ["ή"] = "í", ["θ"] = "th", ["ι"] = "i", ["ί"] = "í", ["ϊ"] = "ï", ["ΐ"..."
 
polytonic modern greek transliterated as monotonic
Line 33: Line 33:
-- transliterates any words or phrases
-- transliterates any words or phrases
function export.tr(text, lang, sc)
function export.tr(text, lang, sc)
-- strip polytonic diacritics if present
if sc == "Polyt" then
text = mw.ustring.toNFD(text)
text = gsub(text, "["
.. U(0x0304) -- macron
.. U(0x0306) -- breve
.. U(0x0313) -- smooth breathing
.. U(0x0314) -- rough breathing
.. U(0x0345) -- iota subscript
.. "]", "")
text = gsub(text, "["
.. U(0x0300) -- grave
.. U(0x0342) -- circumflex
.. "]", acute)
end
text = gsub(gsub(text, "χ̌", "š"), "Χ̌", "Š") -- dialectal
-- dialectal notation
text = gsub(gsub(text, "ά̤", "ä́"), "Ά̤", "Ä́") -- dialectal
if mw.ustring.find(text, "["..U(0x030C)..U(0x0324).."]") then
text = gsub(gsub(text, "α̤", "ä"), "Α̤", "Ä") -- dialectal
text = gsub(gsub(text, "χ̌", "š"), "Χ̌", "Š")
text = gsub(gsub(text, "ό̤", "ö́"), "Ό̤", "Ö́") -- dialectal
text = gsub(gsub(text, "ά̤", "ä́"), "Ά̤", "Ä́")
text = gsub(gsub(text, "ο̤", "ö"), "Ο̤", "Ö") -- dialectal
text = gsub(gsub(text, "α̤", "ä"), "Α̤", "Ä")
text = gsub(gsub(text, "ό̤", "ö́"), "Ό̤", "Ö́")
text = gsub(gsub(text, "ο̤", "ö"), "Ο̤", "Ö")
end


-- Greek interrogation mark
text = gsub(text, "([^A-Za-z0-9])[;" .. erotimatiko .. "]", "%1?")
text = gsub(text, "([^A-Za-z0-9])[;" .. erotimatiko .. "]", "%1?")