Module:Cy-mut
Appearance
local export = {}
PAGENAME = PAGENAME or mw.title.getCurrentTitle().text
local mutation_rules = {
['b'] = {"f", "m",},
['c'] = {"g", "ngh", "ch",},
['ch'] = {},
['d'] = {"dd", "n",},
['f'] = {},
['g'] = {"", "ng"},
['h'] = {},
['l'] = {},
['ll'] = {"l",},
['m'] = {"f",},
['n'] = {},
['p'] = {"b", "mh", "ph",},
['r'] = {},
['rh'] = {"r",},
['s'] = {},
['t'] = {"d", "nh", "th",},
}
function export.show(frame)
args = frame:getParent().args
radical = args[1] or PAGENAME
initial = mw.ustring.sub(radical,1,1)
is_uppercase = mw.ustring.lower(initial) ~= initial
initial = mw.ustring.lower(initial)
final = mw.ustring.sub(radical,2,-1)
first_two = initial .. mw.ustring.sub(final,1,1)
if first_two=='ll' or first_two=='rh' or first_two=='ch' then
initial = first_two
final = mw.ustring.sub(final,2,-1)
end
vowel = false
local mut1 = nil
local mut2 = nil
local mut3 = nil
if mw.ustring.match(initial,'[aâeêiîoôuûwŵyŷ]') then
vowel = true
mut3 = "h" .. initial
elseif mutation_rules[initial] then
mut1 = mutation_rules[initial][1]
mut2 = mutation_rules[initial][2]
mut3 = mutation_rules[initial][3]
else
error('rule not specified for this word:'..radical)
end
local function link(target, accel)
target = target .. final
if is_uppercase then
target = mw.ustring.upper(mw.ustring.sub(target,1,1)) .. mw.ustring.sub(target,2,-1)
end
return target == PAGENAME and "'''"..target.."'''" or '<span class="form-of '..accel..'-form-of lang-cy origin-'..radical..'">[['..target..'#Welsh|'..target..']]</span>'
end
mut1 = mut1 and link(mut1, 'soft')
mut2 = mut2 and link(mut2, 'nasal')
mut3 = mut3 and link(mut3, vowel and 'h-prothesis' or 'aspirate')
radical = radical == PAGENAME and "'''"..radical.."'''" or '[['..radical..'#Welsh|'..radical..']]'
result = '{| 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%;"'
result = result .. '\n|-'
result = result .. '\n! colspan=4 | [[Appendix:Welsh mutations|Welsh mutation]]'
result = result .. '\n|-'
result = result .. '\n! [[radical|radical]] !! [[saft mutation|saft]] !! [[nasal mutation|nasal]] !! ' .. (vouel and '[[h-prothesis|prothesis]]' or '[[aspirate mutation|aspirate]]')
result = result .. '\n|-'
result = result .. '\n| ' .. radical
result = result .. '\n| ' .. (mut1 or "''unchynged''")
result = result .. '\n| ' .. (mut2 or "''unchynged''")
result = result .. '\n| ' .. (mut3 or "''unchynged''")
result = result .. '\n|-'
result = result .. "\n| 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>"
result = result .. '\n|}'
return result
end
return export