Module:goh-common

This module contains common helper functions for Old High German, that are needed by other modules.


local export = {}

-- Make a link out of a form, or show a dash if empty.
function export.link_form(form, tag)
    if not SUBPAGENAME then
        SUBPAGENAME = mw.title.getCurrentTitle().subpageText
    end
 
    if type(form) == "table" then
        for n, subform in pairs(form) do
            form[n] = export.link_form(subform, tag)
        end
        return table.concat(form, ", ")
    else
        if form ~= "" then
            return "<" .. (tag or "span") .. " lang=\"goh\">[[" .. form .. (form ~= PAGENAME and "#Old High German|" .. form or "") .. "]]</" .. (tag or "span") .. ">"
        else
            return "&mdash;"
        end
    end
end

-- When the preterite t is added to a double consonant, or forms one, the double consonants simplify.
function export.dbl_t(word)
    word = word
 
    word = mw.ustring.gsub(word, "bbt", "bt")
    word = mw.ustring.gsub(word, "ccht", "ht")
    word = mw.ustring.gsub(word, "cht", "ht")
    word = mw.ustring.gsub(word, "ckt", "kt")
    word = mw.ustring.gsub(word, "ddt", "dt")
    word = mw.ustring.gsub(word, "fft", "ft")
    word = mw.ustring.gsub(word, "ggt", "gt")
    word = mw.ustring.gsub(word, "hht", "ht")
    word = mw.ustring.gsub(word, "kkt", "kt")
    word = mw.ustring.gsub(word, "llt", "lt")
    word = mw.ustring.gsub(word, "mmt", "mt")
    word = mw.ustring.gsub(word, "nnt", "nt")
    word = mw.ustring.gsub(word, "ppt", "pt")
    word = mw.ustring.gsub(word, "rrt", "rt")
    word = mw.ustring.gsub(word, "sst", "st")
    word = mw.ustring.gsub(word, "zzt", "zt")
 
    return word
end
 
-- Weak 1a verbs feature consonant gemination due to following j.
-- 2nd person singular imperatives did not have this j.
function export.impr_1a(word)
    word = word
 
    word = mw.ustring.gsub(word, "bbi$", "bi")
    word = mw.ustring.gsub(word, "cki$", "ki")
    word = mw.ustring.gsub(word, "ddi$", "di")
    word = mw.ustring.gsub(word, "ffi$", "fi")
    word = mw.ustring.gsub(word, "ggi$", "gi")
    word = mw.ustring.gsub(word, "hhi$", "hi")
    word = mw.ustring.gsub(word, "kki$", "ki")
    word = mw.ustring.gsub(word, "lli$", "li")
    word = mw.ustring.gsub(word, "mmi$", "mi")
    word = mw.ustring.gsub(word, "nni$", "ni")
    word = mw.ustring.gsub(word, "ppi$", "pi")
    word = mw.ustring.gsub(word, "rri$", "ri")
    word = mw.ustring.gsub(word, "ssi$", "si")
    word = mw.ustring.gsub(word, "tti$", "ti")
    word = mw.ustring.gsub(word, "zzi$", "zi")
 
    return word
end
 
-- Double consonants simplify at the end of a word.
function export.dbl_cons(word)
    word = word
 
    word = mw.ustring.gsub(word, "bb$", "b")
    word = mw.ustring.gsub(word, "cch$", "h")
    word = mw.ustring.gsub(word, "ch$", "h")
    word = mw.ustring.gsub(word, "ck$", "k")
    word = mw.ustring.gsub(word, "dd$", "d")
    word = mw.ustring.gsub(word, "ff$", "f")
    word = mw.ustring.gsub(word, "gg$", "g")
    word = mw.ustring.gsub(word, "hh$", "h")
    word = mw.ustring.gsub(word, "kk$", "k")
    word = mw.ustring.gsub(word, "ll$", "l")
    word = mw.ustring.gsub(word, "mm$", "m")
    word = mw.ustring.gsub(word, "nn$", "n")
    word = mw.ustring.gsub(word, "pp$", "p")
    word = mw.ustring.gsub(word, "rr$", "r")
    word = mw.ustring.gsub(word, "ss$", "s")
    word = mw.ustring.gsub(word, "tt$", "t")
    word = mw.ustring.gsub(word, "zz$", "z")
 
    return word
end

return export