Module:Cy-mut

local export = {}

function export.show(frame) PAGENAME = PAGENAME or mw.title.getCurrentTitle.text args = frame:getParent.args radical = args[1] or PAGENAME initial = mw.ustring.sub(radical,1,1) final = mw.ustring.sub(radical,2,-1) if mw.ustring.sub(radical,1,2)=='ll' or mw.ustring.sub(radical,1,2)=='Ll' or mw.ustring.sub(radical,1,2)=='rh' or mw.ustring.sub(radical,1,2)=='Rh' then initial = mw.ustring.sub(radical,1,2) final = mw.ustring.sub(radical,3,-1) end vowel = true if not mw.ustring.match(initial,'^[fhlnrsFHLNRS]$') then if mw.ustring.match(initial,'[aâeêiîoôuûwŵyŷ]') then vowel = true mut3 = "h" .. initial elseif mw.ustring.match(initial,'[AÂEÊIÎOÔUÛWŴYŶ]') then vowel = true mut3 = "H" .. mw.ustring.lower(initial) elseif initial == 'a' then mut1 = "ø" mut2 = "ó" elseif initial == 'B' then mut1 = "F" mut2 = "M" elseif initial == 'c' then mut1 = "g" mut2 = "ngh" mut3 = "ch" elseif initial == 'C' then mut1 = "G" mut2 = "Ngh" mut3 = "Ch" elseif initial == 'd' then mut1 = "dd" mut2 = "n" elseif initial == 'D' then mut1 = "Dd" mut2 = "N" elseif initial == 'g' then mut1 = "" mut2 = "ng" elseif initial == 'G' then mut1 = "" mut2 = "Ng" elseif initial == 'll' then mut1 = "l" elseif initial == 'Ll' then mut1 = "L" elseif initial == 'm' then mut1 = "f" elseif initial == 'M' then mut1 = "F" elseif initial == 'p' then mut1 = "b" mut2 = "mh" mut3 = "ph" elseif initial == 'P' then mut1 = "B" mut2 = "Mh" mut3 = "Ph" elseif initial == 'rh' then mut1 = "r" elseif initial == 'Rh' then mut1 = "R" elseif initial == 't' then mut1 = "d" mut2 = "nh" mut3 = "th" elseif initial == 'T' then mut1 = "D" mut2 = "Nh" mut3 = "Th" else error('rule not specified for this word:'..radical) end end if not mut1 then mut1 = "unchanged" else mut1 = mut1 .. final if initial == "G" then mut1 = mw.ustring.upper(mw.ustring.sub(mut1,1,1)) .. mw.ustring.sub(mut1,2,-1) end mut1 = (mut1 == PAGENAME and ""..mut1.."" or ' '..mut1..' ') end if not mut2 then mut2 = "unchanged" else mut2 = mut2 .. final mut2 = (mut2 == PAGENAME and ""..mut2.."" or ' '..mut2..' ') end if not mut3 then mut3 = "unchanged" else mut3 = mut3 .. final mut3 = (mut3 == PAGENAME and ""..mut3.."" or ''..mut3..' ') end radical = radical == PAGENAME and ""..radical.."" or ..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 | Welsh mutation' result = result .. '\n|-' result = result .. '\n! radical !! soft !! nasal !! ' .. (vowel and 'h-prothesis' or 'aspirate') result = result .. '\n|-' result = result .. '\n| ' .. radical result = result .. '\n| ' .. mut1 result = result .. '\n| ' .. mut2 result = result .. '\n| ' .. mut3 result = result .. '\n|-' result = result .. '\n| ' result = result .. '\n|}' return result end

return export