Jump to content

Module:R:no:Ordbokene

From Wiktionary, the free dictionary

This module is used by {{R:no:Ordbokene}}, {{R:nb:Ordbokene}} and {{R:nn:Ordbokene}} to interface with the two dictionaries Bokmålsordboka ("The Bokmål Dictionary") and Nynorskordboka ("The Nynorsk Dictionary"), both hosted at https://ordbokene.no. This module should normally NOT be called directly, but be used through those templates.

This module is called like this:

{{#invoke:R:no:Ordbokene|main}}

Optionally, one of the dictionaries may be chosen, either Nynorsk – nn – or Bokmål – nb, e.g.:

{{#invoke:R:no:Ordbokene|main|nn}}

local p = {}

function p.main(frame)

	local templateLang = frame.args[1]
	local params = {
		[1] = {},
		["lang"] = {},
	}
	local args = require("Module:parameters").process(frame:getParent().args, params)

	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 = 'bm'
		specifier2 = "''The Bokmål Dictionary''"
	elseif lang == 'nn'  then
		specifier = 'nn'
		specifier2 = "''The Nynorsk Dictionary''"
	elseif lang == 'no' then
		specifier = 'bm,nn'
		specifier2 = "''The Bokmål Dictionary'' / ''The Nynorsk Dictionary''"
	end

	target = args[1] or mw.loadData("Module:headword/data").pagename

	template = "[https://ordbokene.no/" .. specifier .. "/search?q=" .. (mw.ustring.gsub(target, " ", "%%20")) ..
	" “" .. target .. "”] in " .. specifier2 .. "."
	return template
end

return p