မေႃႇၵျူး:SDcat
Lua module ဢၼ်ၼႆႉ လႆႈၸႂ်ႉဝႆႉ တီႈၼႃႈလိၵ်ႈ many ၼႃႈလိၵ်ႈ လႄႈ လွင်ႈလႅၵ်ႈလၢႆႈၸိူဝ်းၼႆႉ တေႁႂ်ႈၽၢင်ႉမႅၼ်ႈၺႃး ၵႂၢင်ႈၵႂၢင်ႈၶႂၢင်ၶႂၢင်။ ၸၢမ်းတူၺ်း လွင်ႈလႅၵ်ႈလၢႆႈ တီႈၼႂ်း မေႃႇၵျူး's /sandbox ဢမ်ႇၼၼ် ၼႃႈလိၵ်ႈၽႄ /testcases . ဝူၼ်ႉသွၼ်ႇ ဢုပ်ႇဢူဝ်း လွင်ႈလႅၵ်ႈလၢႆႈ တီႈၼႂ်း ၼႃႈလိၵ်ႈ တႃႇဢုပ်ႇ ၽွင်းမိူဝ်ႈပႆႇ ၵေႃႇသၢင်ႈၶဝ်ၼၼ်ႉ။
ႁူဝ်ၼပ်ႉ လွင်ႈၶဝ်ႈပႃးၼႆႉ မၼ်းႁဵတ်းဢၢပ်ႉတဵတ်ႉဝႆႉႁင်းမၼ်း (တူၺ်းတီႈ ၽိုၼ်လိၵ်ႈ)။ |
moduleဢၼ်ၼႆႉ မၼ်း ၶဝ်ႈပႃးဝႆႉ တီႈၼႂ်း ၼႃႈလိၵ်ႈ ဢၼ်ၵွင်ႉၵၢႆႇႁႄႉၵင်ႈဝႆႉ ၊ ယွၼ်ႉၼၼ်လႄႈ ၸိူဝ်းပဵၼ် ၽူႈၵမ်ၵၢၼ်ၶဝ်ၵူၺ်း တေၸၢင်ႈမႄးထတ်း မၼ်းလႆႈ။ |
Module to check whether local short description matches that on Wikidata
setCat has the qid of a Wikidata entity passed as |qid= (it defaults to the associated qid of the current article if omitted) and the local short description passed as |sd= It returns a category if there is an associated Wikidata entity.
It returns one of the following tracking categories, as appropriate:
- Category:Short description matches Wikidata (case-insensitive)
- Category:Short description is different from Wikidata
- Category:Short description with empty Wikidata description
For testing purposes, a link prefix |lp= may be set to ":" to make the categories visible.
လွင်ႈၸႂ်ႉတိုဝ်း
မႄးထတ်း- From within a template
{{SDcat |sd={{{shortdescription|}}} }}
- or
{{#invoke:SDcat |setCat |sd={{{shortdescription|}}} }}
Template:SDcat is a wrapper for this module.
- From another module
sdcat = require("Module:SDcat")._setCat
local tracking_cat = sdcat(shortdesc, itemID)
တွၼ်ႈတႃႇၸၢမ်းတူၺ်း
မႄးထတ်း{{#invoke:SDcat |setCat |qid={{get QID|Douglas Adams}}|sd=English author and humorist (1952–2001) |lp=":"}}
A few examples of tests are at Module talk:SDcat
ၽိုၼ်ၵႅမ်မိုဝ်းလၢႆးၸႂ်ႉတိုဝ်း (documentation)တီႈၽၢႆႇၼိူဝ်ၼႆႉ လုၵ်ႉတီႈ မေႃႇၵျူး:SDcat/doc သေ ၶၢႆႉသႂ်ႇၶဝ်ႈ (ႁဵတ်း transclude ဝႆႉၶႃႈဢေႃႈ။ (မႄးထတ်း | ပိုၼ်း) ၽူႈၸိူဝ်းမႄးထတ်းၶဝ် ၸၢင်ႈၸၢမ်းတူၺ်းလႆႈ ၸိူဝ်းပဵၼ်ၼႃႈလိၵ်ႈ sandbox (သၢင်ႈ | ငဝ်းမိူၼ်) လႄႈ testcases (သၢင်ႈ) ႁင်း မေႃႇၵျူးဢၼ်ၼႆႉ လႆႈယူႇၶႃႈ။ ၼႃႈလိၵ်ႈၽႄ ႁင်း မေႃႇၵျူး ဢၼ်ၼႆႉ။. |
--[[
SDcat
Module to check whether local short description matches that on Wikidata
--]]
local p = {}
-------------------------------------------------------------------------------
--[[
setCat has the qid of a Wikidata entity passed as |qid=
(it defaults to the associated qid of the current article if omitted)
and the local short description passed as |sd=
It returns a category if there is an associated Wikidata entity.
It returns one of the following tracking categories, as appropriate:
* Category:Short description matches Wikidata (case-insensitive)
* Category:Short description is different from Wikidata
* Category:Short description with empty Wikidata description
For testing purposes, a link prefix |lp= may be set to ":" to make the categories visible.
--]]
-- function exported for use in other modules
-- (local short description, Wikidata entity-ID, link prefix)
p._setCat = function(sdesc, itemID, lp)
if not mw.wikibase then return nil end
if itemID == "" then itemID = nil end
-- Wikidata description field
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 exported for call from #invoke
p.setCat = function(frame)
local args
if frame.args.sd then
args = frame.args
else
args = frame:getParent().args
end
-- local short description
local sdesc = mw.text.trim(args.sd or ""):lower()
-- Wikidata entity-ID
local itemID = mw.text.trim(args.qid or "")
-- link prefix, strip quotes
local lp = mw.text.trim(args.lp or ""):gsub('"', '')
return p._setCat(sdesc, itemID, lp)
end
return p