模組:Redlink category
外观
local export = {}
function export.cat (frame)
local redlink_category = ""
if pcall(mw.incrementExpensiveFunctionCount) then
local m_languages = require("Module:languages")
local code = frame.args[1] -- language code
local template = frame.args["template"]
local lang = m_languages.getByCode(frame.args[1])
local langname = lang:getCanonicalName()
local text = lang:makeEntryName(frame.args[2]) -- entry name (parameter 2 in Template:m, Template:l)
local link_object = mw.title.new (text) or nil
local link_id = link_object.id
if link_object.id == 0 then
redlink_category = "[[Category:" .. langname .. "紅鏈]]"
if template and template ~= "-" then
redlink_category = redlink_category .. "[[Category:" .. langname .. "紅鏈/" .. template .. "]]"
end
end
end
return redlink_category
end
return export