Jump to content

Module:ga-mutation

From Wiktionary, the free dictionary

Used to render {{ga-mut}}. The actual "brains" of the module are in Module:ga-common.


local m_links = require("Module:links")

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

local export = {}


local function repl(forms, param)
	if param ~= "normal" and forms[param] == forms["normal"] then
		return "''not applicable''"
	end
	
	local ret = m_links.full_link({lang = lang, term = forms[param]})
	
	if param == "len" and forms.an ~= forms.normal then
		ret = ret .. "<br/>''after " .. m_links.full_link({lang = lang, alt = "an"}) .. ",'' " .. m_links.full_link({lang = lang, term = forms.an})
	end
	
	return ret
end


local table_cons = [=[
! radical
! lenition
! eclipsis
|-
| {{{normal}}}
| {{{len}}}
| {{{ecl}}}
]=]


local table_vowel = [=[
! radical !! eclipsis !! with ''h''-prothesis !! with ''t''-prothesis
|-
| {{{normal}}}
| {{{ecl}}}
| {{{hpro}}}
| {{{tpro}}}
]=]


function export.mut(frame)
	local params = {
		[1] = {},
		}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local title = mw.title.getCurrentTitle().subpageText
	local forms = require("Module:ga-common").mutations(title, args[1])
	local wikicode = mw.ustring.find(mw.ustring.lower(title), "^[aeiouáéíóú]") and table_vowel or table_cons
	
	local result = frame:expandTemplate{ 
		title = 'inflection-table-top', 
		args = {
			title = '[[Appendix:Irish mutations|Mutated forms]] of ' .. require("Module:links").full_link({lang = lang, alt = title}, 'term'),
			palette = 'orange'
		}
	}
	result = result .. '\n'
	result = result .. mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", function(param) return repl(forms, param) end)
	result = result .. frame:expandTemplate{ 
		title = 'inflection-table-bottom', 
		args = {
			notes = '<p style="font-size:85%;"><i>Note:</i> Certain mutated forms of some words can never occur in standard Modern Irish.<br>All possible mutated forms are displayed for convenience.</p>'
		}
	}
	
	return result
end

return export