Jump to content

Module:SDcat: Difference between revisions

From Wikipedia, the free encyclopedia
Created page with " --SDcat Module to check whether local short description matches the Wikidata description. local p = {} -- Compare local short description with Wikidata p._setCat = function(sdesc, itemID, lp) if not mw.wikibase then return nil end if itemID == "" then itemID = nil end local wdesc = (mw.wikibase.getDescription(itemID) or ""):lower() if wdesc == "" then return "" .. lp .. "Category:Short description with empty W..."
 
Blanked the page
Tag: Blanking
 
Line 1: Line 1:


--[[
SDcat
Module to check whether local short description
matches the Wikidata description.
]]
local p = {}
-- Compare local short description with Wikidata
p._setCat = function(sdesc, itemID, lp)
    if not mw.wikibase then
        return nil
    end
    if itemID == "" then
        itemID = nil
    end
    local wdesc = (mw.wikibase.getDescription(itemID) or ""):lower()
    if wdesc == "" then
        return "[[" .. lp .. "Category:Short description with empty Wikidata description]]"
    elseif wdesc == sdesc then
        return "[[" .. lp .. "Category:Short description matches Wikidata]]"
    else
        return "[[" .. lp .. "Category:Short description is different from Wikidata]]"
    end
end
-- Function called by templates
p.setCat = function(frame)
    local args
    if frame.args.sd then
        args = frame.args
    else
        args = frame:getParent().args
    end
    local sdesc = mw.text.trim(args.sd or ""):lower()
    local itemID = mw.text.trim(args.qid or "")
    local lp = mw.text.trim(args.lp or ""):gsub('"', '')
    return p._setCat(sdesc, itemID, lp)
end
return p

Latest revision as of 13:45, 23 November 2026