Module:egy-rom-variant

From Wiktionary, the free dictionary
Jump to navigation Jump to search


local export = {}
local PAGENAME = mw.title.getCurrentTitle().text

local lang = require("Module:languages").getByCode("egy")

function export.common(word)
	if type(word) == "table" then
		word = word.args[1] or word:getParent().args[1]
	end
	if not word or (word == "") then
		word = PAGENAME
	end

	return word
end

function export.to_MDC(word)
    mdc = export.common(word)

	mdc = mw.ustring.gsub(mdc, "ꜣ", "A")
	mdc = mw.ustring.gsub(mdc, "j", "i")
	mdc = mw.ustring.gsub(mdc, "ï", "y")
	mdc = mw.ustring.gsub(mdc, "ꜥ", "a")
	mdc = mw.ustring.gsub(mdc, "ḥ", "H")
	mdc = mw.ustring.gsub(mdc, "ḫ", "x")
	mdc = mw.ustring.gsub(mdc, "ẖ", "X")
	mdc = mw.ustring.gsub(mdc, "š", "S")
	mdc = mw.ustring.gsub(mdc, "ṯ", "T")
	mdc = mw.ustring.gsub(mdc, "ḏ", "D")
	mdc = mw.ustring.gsub(mdc, ",", "")
	mdc = mw.ustring.gsub(mdc, "⸗", ".")

	return mdc
end

function export.to_Gardiner(word)
    gardiner = export.common(word)

	gardiner = mw.ustring.gsub(gardiner, "j", "ꞽ")
	gardiner = mw.ustring.gsub(gardiner, "ï", "y")
	gardiner = mw.ustring.gsub(gardiner, "z", "s")
	gardiner = mw.ustring.gsub(gardiner, "q", "ḳ")
	gardiner = mw.ustring.gsub(gardiner, ",", "")
	gardiner = mw.ustring.gsub(gardiner, "%.", "·")
	gardiner = mw.ustring.gsub(gardiner, "⸗", "·")

	return gardiner
end

function export.to_e_g(word)
    e_g = export.common(word)

	e_g = mw.ustring.gsub(e_g, "s,", "s")
	e_g = mw.ustring.gsub(e_g, "%.jn⸗?", "-jn")
	e_g = mw.ustring.gsub(e_g, "%.ḫr⸗?", "-ḫr")
	e_g = mw.ustring.gsub(e_g, "%.kꜣ⸗?", "-kꜣ")
	e_g = mw.ustring.gsub(e_g, "%f[%a%.,·⸗]j", "ꞽ")
	e_g = mw.ustring.gsub(e_g, "ï", "j")
	e_g = mw.ustring.gsub(e_g, "y", "j")
	e_g = mw.ustring.gsub(e_g, ",wt", "w,t")
	e_g = mw.ustring.gsub(e_g, ",w", "w")
	e_g = mw.ustring.gsub(e_g, ",jt", "j,t")
	e_g = mw.ustring.gsub(e_g, ",j", "j")
	e_g = mw.ustring.gsub(e_g, ",tt", ",t,t")
	e_g = mw.ustring.gsub(e_g, "s", "ś")
	e_g = mw.ustring.gsub(e_g, "z", "s")
	e_g = mw.ustring.gsub(e_g, "q", "ḳ")
	e_g = mw.ustring.gsub(e_g, ",", "·")
	e_g = mw.ustring.gsub(e_g, "%.", "")
	e_g = mw.ustring.gsub(e_g, "ꞽw⸗", "ꞽw")
	e_g = mw.ustring.gsub(e_g, "⸗", "·") -- inconsistently; sometimes omitted

	return e_g
end

function export.to_Lepsius(word)
    lepsius = export.common(word)

	lepsius = mw.ustring.gsub(lepsius, ",wt", "w-t") -- historically tw instead, but this was based on a misreading
	lepsius = mw.ustring.gsub(lepsius, ",yt", "y-t")
	lepsius = mw.ustring.gsub(lepsius, ",jt", "j-t")
	lepsius = mw.ustring.gsub(lepsius, ",tt", "t-t")
	lepsius = mw.ustring.gsub(lepsius, ",t", "-t")
	lepsius = mw.ustring.gsub(lepsius, "s,", "se-")
	lepsius = mw.ustring.gsub(lepsius, "%.jn", " jn")
	lepsius = mw.ustring.gsub(lepsius, "%.ḫr", " ḫr")
	lepsius = mw.ustring.gsub(lepsius, "%.kꜣ", " kꜣ")
	lepsius = mw.ustring.gsub(lepsius, "ꜣ", "a")
	lepsius = mw.ustring.gsub(lepsius, "j", "ȧ")
	lepsius = mw.ustring.gsub(lepsius, "ï", "i")
	lepsius = mw.ustring.gsub(lepsius, "y", "ī")
	lepsius = mw.ustring.gsub(lepsius, "ꜥ", "ā")
	-- lepsius = mw.ustring.gsub(lepsius, "rw", "l") -- only when represented by the lion glyph
	lepsius = mw.ustring.gsub(lepsius, "w", "u")
	lepsius = mw.ustring.gsub(lepsius, "ḫ", "χ")
	lepsius = mw.ustring.gsub(lepsius, "ẖ", "χ")
	lepsius = mw.ustring.gsub(lepsius, "z", "s")
	lepsius = mw.ustring.gsub(lepsius, "g", "ḳ")
	lepsius = mw.ustring.gsub(lepsius, "ṯ", "θ")
	lepsius = mw.ustring.gsub(lepsius, "d", "ṭ")
	lepsius = mw.ustring.gsub(lepsius, ",", "")
	lepsius = mw.ustring.gsub(lepsius, "%.", "")
	lepsius = mw.ustring.gsub(lepsius, "%f[%a]n⸗", "n")
	lepsius = mw.ustring.gsub(lepsius, "⸗", "-")
	
	-- e-epenthesis
	lepsius = mw.ustring.gsub(lepsius, "%f[%a]([mnr])%f[%A]", "e%1")
	lepsius = mw.ustring.gsub(lepsius, "%f[%a]nt", "ent")
	lepsius = mw.ustring.gsub(lepsius, "([aȧiīāue])([bpfmnrlhḥχsšqkḳtθṭḏ])([bpfmnrlhḥχsšqkḳtθṭḏ])([aȧiīāue])", "%1%2v%3%4")
	lepsius = mw.ustring.gsub(lepsius, "([mnr])([bpfhḥχsšqkḳtθṭḏ])%f[%A]", "%1v%2")
	lepsius = mw.ustring.gsub(lepsius, "([fhḥχsšθ])([bpqkḳtṭḏ])%f[%A]", "%1v%2")
	lepsius = mw.ustring.gsub(lepsius, "%f[%a]([mnrfhḥχsšθ])v([bpfhḥχsšqkḳtθṭḏ])%f[%A]", "%1e%2")
	lepsius = mw.ustring.gsub(lepsius, "([bpfmnrlhḥχsšqkḳtθṭḏ])([bpfmnrlhḥχsšqkḳtθṭḏ])", "%1e%2")
	lepsius = mw.ustring.gsub(lepsius, "([bpflhḥχsšqkḳtθṭḏ])([bpfmnrlhḥχsšqkḳtθṭḏ])%f[%A]", "%1e%2")
	lepsius = mw.ustring.gsub(lepsius, "v", "")
	lepsius = mw.ustring.gsub(lepsius, "([aȧiīāue])([bpfmnrlhḥχsšqkḳtθṭḏ])e([bpfmnrlhḥχsšqkḳtθṭḏ])e", "%1%2%3e")

	lepsius = mw.ustring.gsub(lepsius, "ḏ", "t′")

	return lepsius
end

return export