Module:StageQuotes

From Inkipedia, the Splatoon wiki

For use with Template:StageQuotes.


local p = {}

function p.GenerateStageQuotes(frame)
    local templateargs ={
        Qopen='“',
        Qclose='”',
        [':']=':',
        C='Callie',
        M='Marie',
        Ccolor='{{TextColor|Callie}}',
        Mcolor='{{TextColor|Marie}}',
        game='Splatoon',
        language='Eng'
    }
    local parentframeargs = frame:getParent().args
    local lang = parentframeargs.language or templateargs.language
    --Get the character names and punctuation per language:
    local charnameseng = {'Callie', 'Marie', 'Pearl', 'Marina'}
    local charnames = charnameseng
    if lang == 'Jap' then
        charnames = {'アオリ', 'ホタル', 'ヒメ', 'イイダ'}
        templateargs.Qopen='「'
        templateargs.Qclose='」'
        templateargs[':']=':'
    elseif lang == 'Dut' then
        charnames = {'Callie', 'Marie', 'Lorelei', 'Mariana'}
    elseif lang == 'Fre' then
        charnames = {'Ayo', 'Oly', 'Perle', 'Coralie'}
        templateargs.Qopen='« '
        templateargs.Qclose=' »'
        templateargs[':']=' :'
    elseif lang == 'Ger' then
        charnames = {'Aioli', 'Limone', 'Perla', 'Marina'}
        templateargs.Qopen='„'
        templateargs.Qclose='“'
    elseif lang == 'Ita' then
        charnames = {'Stella', 'Marina', 'Alga', 'Nori'}
        templateargs.Qopen='«'
        templateargs.Qclose='»'
    elseif lang == 'Rus' then
        charnames = {'Кэлли', 'Мари', 'Жемчик', 'Мариша'}
        templateargs.Qopen='«'
        templateargs.Qclose='»'
    elseif lang == 'Spa' then
        charnames = {'Mar', 'Tina', 'Perla', 'Marina'}
        templateargs.Qopen='«'
        templateargs.Qclose='»'
    elseif lang == 'SpaE' then
        charnames = {'Mar', 'Tina', 'Perla', 'Marina'}
        templateargs.Qopen='«'
        templateargs.Qclose='»'
    elseif lang == 'SpaA' then
        charnames = {'Mar', 'Tina', 'Perla', 'Marina'}
    elseif lang == 'ChiS' then
        templateargs[':']=':'
    elseif lang == 'ChiT' then
        templateargs.Qopen='「'
        templateargs.Qclose='」'
        templateargs[':']=':'
    elseif lang == 'Kor' then
        charnames = {'아오리', '호타루', 'Pearl', 'Marina'}
    end --'Eng' is handled by default
    --Game-specific settings:
    local game = parentframeargs.game or templateargs.game
    local idx1=1
    local idx2=2
    if game == 'Splatoon 2' then
        idx1=3
        idx2=4
    end
    templateargs.C=charnames[idx1]
    templateargs.CEng=charnameseng[idx1]
    templateargs.Ccolor=frame:expandTemplate{ title='TextColor', args= { templateargs.CEng } }
    templateargs.M=charnames[idx2]
    templateargs.MEng=charnameseng[idx2]
    templateargs.Mcolor=frame:expandTemplate{ title='TextColor', args= { templateargs.MEng } }
    templateargs.game = game
    --Use the default only for unspecified parameters:
    for k,v in pairs(templateargs) do
        if parentframeargs[k] ~= nil then
            templateargs[k] = parentframeargs[k]
        end
    end
    
    local ret =''
    
    local numquotes=16
    if parentframeargs['numquotes'] then
        local nq = tonumber(parentframeargs['numquotes'])
        if nq then
            numquotes=nq
        end
    end
    for i=1,numquotes do
        templateargs.Cface = parentframeargs['C'..i..'face'] or ''
        templateargs.Mface = parentframeargs['M'..i..'face'] or ''
        --Quote #A
        if parentframeargs['C'..i..'A'] then
            templateargs.Cquote = parentframeargs['C'..i..'A'] or ''
            templateargs.Mquote = parentframeargs['M'..i..'A'] or ''
            templateargs.CquoteEng = parentframeargs['C'..i..'Aeng'] or ''
            templateargs.MquoteEng = parentframeargs['M'..i..'Aeng'] or ''
            templateargs.R = parentframeargs['R'..i..'A'] or ''
            ret = ret..'|- valign=top\n'..frame:expandTemplate{ title='StageQuote', args = templateargs }..'\n'
        end
        --Quote #B
        if parentframeargs['C'..i..'B'] then
            templateargs.Cquote = parentframeargs['C'..i..'B'] or ''
            templateargs.Mquote = parentframeargs['M'..i..'B'] or ''
            templateargs.CquoteEng = parentframeargs['C'..i..'Beng'] or ''
            templateargs.MquoteEng = parentframeargs['M'..i..'Beng'] or ''
            templateargs.R = parentframeargs['R'..i..'B'] or ''
            ret = ret..'|- valign=top\n'..frame:expandTemplate{ title='StageQuote', args = templateargs }..'\n'
        end
        if parentframeargs['Notes'..i] then
            ret = ret..'|-\n|colspan=3 style="background-color:#EED"|Notes: '..parentframeargs['Notes'..i]..'\n'
        end
    end
    
    return ret
end

return p