Jump to content

Module:SDcat

From Wikipedia, the free encyclopedia
Revision as of 13:44, 23 November 2026 by Aletopedia (talk | contribs) (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...")
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

--[[ 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