Module:R:NAOB

From Wiktionary, the free dictionary
Jump to navigation Jump to search
This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local p = {}
 
function p.main(frame)
    local PAGENAME = mw.title.getCurrentTitle().text
    local params = {
		[1] = {},
		["searchmode"] = {},
	}
	local args, invalid_args, invalid_args_warning = require("Module:checkparams").process(frame:getParent(), params)
    
	if args['searchmode'] then
        searchmode = args['searchmode']
    else
        searchmode = 'ordbok'
    end
	
	if searchmode == 'søk' then
		searchmode_ = 'søk'
	elseif searchmode == 'search'  then
		searchmode_ = 'søk'
	else
		searchmode_ = 'ordbok'
	end
		
    target = args[1] or PAGENAME
	target_ = target:gsub(' ', '%%20')

    template = "[https://www.naob.no/" .. searchmode_ .. "/" .. target_ ..
    " “" .. target .. "”] in ''Det Norske Akademis ordbok'' (''NAOB'')."
    return template .. invalid_args_warning
end
 
return p