Jump to content

Module:Ga-mutation

Frae Wikipedia, the free beuk o knawledge
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 = [=[
{| border="1" cellpadding="4" cellspacing="0" class="inflection-table" style="align: left; margin: 0.5em 0 0 0; border-style: solid; border: 1px solid #7f7f7f; border-right-width: 2px; border-bottom-width: 2px; border-collapse: collapse; background-color: #F8F8F8; font-size: 95%;"
|-
! colspan="3" | [[Appendix:Erse mutations|Erse mutation]]
|-
! Radical
! Lenition
! Eclipsis
|-
| {{{normal}}}
| {{{len}}}
| {{{ecl}}}
|-
| colspan="3" | <small style="font-size:85%;">''Note:'' Some o thir forms mey be hypothetical. Nae ivery<br />possible mutatit form o ivery wird actually occurs.</small>
|}]=]


function export.mut_cons(frame)
	local params = {
		[1] = {required = true, default = "{{{1}}}"},
		[2] = {required = true, default = "{{{2}}}"},
		}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local forms = require("Module:ga-common").mutations(args[1] .. args[2])
	
	return (mw.ustring.gsub(table_cons, "{{{([a-z0-9_]+)}}}", function(param) return repl(forms, param) end))
end


local table_vowel = [=[
{| border="1" cellpadding="4" cellspacing="0" class="inflection-table" style="align: left; margin: 0.5em 0 0 0; border-style: solid; border: 1px solid #7f7f7f; border-right-width: 2px; border-bottom-width: 2px; border-collapse: collapse; background-color: #F8F8F8; font-size: 95%;"
|-
! colspan="4" | [[Appendix:Erse mutations|Erse mutation]]
|-
! Radical !! Eclipsis !! wi ''h''-prothesis !! wi ''t''-prothesis
|-
| {{{normal}}}
| {{{ecl}}}
| {{{hpro}}}
| {{{tpro}}}
|-
| colspan="4" | <small style="font-size:85%;">''Note:'' Some o thir forms mey be hypothetical. Nae ivery<br />possible mutatit form o ivery wird actually occurs.</small>
|}]=]


function export.mut_vowel(frame)
	local params = {
		["uc"] = {type = "boolean"},
		}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local forms = require("Module:ga-common").mutations(mw.title.getCurrentTitle().subpageText, "msn")
	
	return (mw.ustring.gsub(table_vowel, "{{{([a-z0-9_]+)}}}", function(param) return repl(forms, param) end))
end


function export.mut(frame)
	local params = {
		[1] = {},
		}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local forms = require("Module:ga-common").mutations(mw.title.getCurrentTitle().subpageText, args[1])
	local wikicode = mw.ustring.find(mw.ustring.lower(mw.title.getCurrentTitle().subpageText), "^[aeiouáéíóú]") and table_vowel or table_cons
	
	return (mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", function(param) return repl(forms, param) end))
end

return export