Module:Njardarlogar/Nn-verb-1

From Wikipedia
Jump to: navigation, search

Documentation for this module may be created at Module:Njardarlogar/Nn-verb-1/doc

local p = {}
 
function p.link(curr_page, target)
    target = (target or curr_page)
    local link
    if curr_page == target then
        link = target
    else
        link = "[[" .. target .. "#Norwegian Nynorsk|" .. target .. "]]"
    end
    return "<b lang='nn'>" .. link .. "</b>"
end
 
function p.main_helper(namespace, pagename)
    local rot = pagename:sub(1, pagename:len() - 1)
    local ret =
        p.link(pagename) ..
        " (''present tense'' " .. p.link(pagename, rot .. "ar") .. "; " ..
        "''past tense and past participle'' " .. p.link(pagename, rot .. "a") ..
        "; ''passive infinitive'' " .. p.link(pagename, rot .. "ast") .. ";" ..
        " ''present participle'' " .. p.link(pagename, rot .. "ande") .. "; " ..
        "''imperative'' " .. p.link(pagename) .. "/" .. p.link(pagename, rot) ..
        ")"
    if namespace == "" then
        ret = ret .. "[[Category:Norwegian Nynorsk verbs]]"
        if not pagename:find("[ae]$") then
            ret =
                ret ..
                "<span class='attentionseeking' lang='nn' " ..
                "title='This template expects a verb in -a or -e'></span>" ..
                "[[Category:Norwegian Nynorsk words needing attention]]"
        end
    end
    return ret
end
 
function p.main(frame)
    return p.main_helper(frame:preprocess('{{NAMESPACE}}'),
                         frame:preprocess('{{PAGENAME}}'))
end
 
return p