Module:User:Catsidhe

-- this is all so very experimental. If anything works, I hope to hive it off -- proper modules for people to use. Do not expect anything here to work, -- or be within eyeshot of reasonable style.

local export = {}; local ga = {}; local sga = {};

function ga.lenite ( frame ) -- when called from a template, lenites the first argument according to -- modern Irish rules and orthography. If an argument of ...|art=|... -- is supplied, it will trigger slightly different rules for lenition -- of "s" after "an". local retval local word = frame.args[1] local haitch = "h" -- default to lowercase or Titlecase if mw.ustring.match( word, "^%u%u" ) then haitch = "H" -- unless the first two letters are uppercase, in which case -- assume it's UPPERCASE. end if mw.ustring.match( word, "^[bBcCdDfFgGmMpPtT][^hH]" ) then -- straightforward consonants retval = mw.ustring.gsub( word, "^(.)", "%1" .. haitch ) elseif mw.ustring.match( word, "^[sS][^hHcCmMpPtT]" ) then -- "s" is more complicated. if frame.args.art then retval = "t" .. word else retval = mw.ustring.gsub( word, "^(.)", "%1" .. haitch ) end else -- if initial vowel, or already lenited, or /S[cmpt]/, -- or one of those strange foreign letters like "k" or "z", -- then don't touch it. retval = word end return retval end

function ga.eclipse ( frame ) local retvar local word = frame.args[1] local eclipsis = { ["a"] = "n-a", ["A"] = "nA", ["á"] = "n-á", ["Á"] = "nÁ", ["b"] = "mb",  ["B"] = "mB", ["c"] = "gc",  ["C"] = "gC", ["d"] = "nd",  ["D"] = "nD", ["e"] = "n-e", ["E"] = "nE", ["é"] = "n-é", ["É"] = "nÉ", ["f"] = "bhf", ["F"] = "bhF", ["g"] = "ng",  ["G"] = "nG", ["i"] = "n-i", ["I"] = "nI", ["í"] = "n-í", ["Í"] = "nÍ", ["o"] = "n-o", ["O"] = "nO", ["ó"] = "n-ó", ["Ó"] = "nÓ", ["p"] = "bp",  ["P"] = "bP", ["t"] = "dt",  ["T"] = "dT", ["u"] = "n-u", ["U"] = "nU", ["ú"] = "n-ú", ["Ú"] = "nÚ" }	return( mw.ustring.gsub( word, "^.", eclipsis ) ) end

function sga.lenite ( frame ) local retval local word = frame.args[1] local lenition = { ['c'] = 'ch',  ['C'] = 'Ch', ['f'] = 'ḟ',   ['F'] = 'Ḟ', ['p'] = 'ph',  ['P'] = 'Ph', ['s'] = 'ṡ',   ['S'] = 'Ṡ', ['t'] = 'th',  ['T'] = 'Th' }	return( mw.ustring.gsub( word, "^.", lenition ) ) end

function sga.nasalise ( frame ) local retval local word = frame.args[1] if mw.ustring.match( word, "^[aádeégiíoóuú]" ) then retval = "n-" .. word elseif mw.ustring.match( word, "^[AÁDEÉGIÍOÓUÚ]" ) then retval = "n" .. word elseif mw.ustring.match( word, "^b" ) then retval = "m-" .. word elseif mw.ustring.match( word, "^B" ) then retval = "m" .. word else retval = word end return retval end

export.lenite = ga.lenite export.eclipse = ga.eclipse export.nasalise = sga.nasalise export.sga_lenite = sga.lenite

return export;