ข้ามไปเนื้อหา

มอดูล:R:The Bokmål and Nynorsk dictionaries

จาก วิกิพจนานุกรม พจนานุกรมเสรี

This module is used by Template:R:The Bokmål and Nynorsk dictionaries to interface with these two dictionaries. That template is in turn used by Template:R:The_Nynorsk_Dictionary and Template:R:The_Bokmål_Dictionary. See documentation there for usage information. This module should normally NOT be called directly, but be used through those templates.

This module is called like this:

{{#invoke:R:The Bokmål and Nynorsk dictionaries|main}}

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

{{#invoke:R:The Bokmål and Nynorsk dictionaries|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.title.getCurrentTitle().text

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

return p