Module:Template:R:Dokumentasjonsprosjektet

local p = {}
 
function p.encode(task)
    res = task:gsub('æ', 'ae')
    res = res:gsub('ø', 'oe')
    res = res:gsub('å', 'aa')
    res = res:gsub(' ', '+')
    return res
end
 
 
function p.main(frame)
    WTpage = frame:preprocess('{{PAGENAME}}')
    args = frame:getParent().args
    if args['lang'] then
        lang = args['lang']
    else
        lang = 'no'
    end
    if lang == 'nb' then
        specifier = '&bokmaal=+&ordbok=bokmaal'
        specifier2 = "''The Bokmål Dictionary''"
    elseif lang == 'nn'  then
        specifier = '&nynorsk=+&ordbok=nynorsk'
        specifier2 = "''The Nynorsk Dictionary''"
    elseif lang == 'no' then
        specifier = '&begge=&begge=+&ordbok=begge'
        specifier2 = "''The Bokmål Dictionary'' / ''The Nynorsk Dictionary''"
    end
    
    if args[1] then
        target_ = args[1]
        target = p.encode(target_)
        
    else
        target_ = WTpage
        target = p.encode(target_)
    end
        
    template = "[http://www.nob-ordbok.uio.no/perl/ordbok.cgi?OPP=" .. target .. specifier ..
    "&alfabet=o “" .. target_ .. "”] in " .. specifier2 .. "."
    return template
end
 
return p