跳至內容

模組:attention

Ùi Wiktionary

可在模組:attention/doc建立此模組的說明文件

local m_params = require("Module:parameters")
local m_params_data = mw.loadData("Module:parameters/data").attention
local format_categories = require("Module:utilities").format_categories

local export = {}

function export.show(frame)
	local args = m_params.process(frame:getParent().args, m_params_data.show)
	
	local lang_code = args[1]
	local title = args[2] and mw.text.encode(args[2])
	local id = args["id"] and mw.uri.anchorEncode(args["id"]) or ""
	
	local categories = {}
	
	if not args["nocat"] then
		local lang = require("Module:languages").getByCode(lang_code, 1)
		
		table.insert(categories, format_categories({"Requests for attention concerning " .. lang:getCanonicalName()}, lang))
		
		if not (title or mw.title.getCurrentTitle().nsText == "Template") then
			table.insert(categories, format_categories({"attention lacking explanation"}, lang, "-"))
		end
	end
	
	local ret = mw.html.create("span")
		:attr("id", "attentionseeking" .. lang_code .. id)
		:addClass("attentionseeking")
		:attr("lang", lang_code)
	
	if title then
		ret = ret:attr("title", title)
	end
	
	return tostring(ret) .. table.concat(categories)
end

return export