မဝ်ဂျူ:R:The Bokmål and Nynorsk dictionaries

နူ ဝိက်ရှေန်နရဳ

Documentation for this module may be created at မဝ်ဂျူ:R:The Bokmål and Nynorsk dictionaries/doc

local p = {}
 
function p.main(frame)
    local PAGENAME = mw.title.getCurrentTitle().text
    
    local templateLang = frame.args[1]
    local args = frame:getParent().args
    
    local lang
    
    if templateLang and templateLang ~= '' then
    	lang = templateLang
    else
	    if args['lang'] then
	        lang = args['lang']
	    else
	        lang = 'no'
	    end
    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
    
    description = args[1] or PAGENAME
    target = description:gsub(' ', '+')
        
    template = "[https://ordbok.uib.no/perl/ordbok.cgi?OPP=" .. target .. specifier ..
    " “" .. description .. "”] in " .. specifier2 .. "."
    return template
end
 
return p