Anda dapat membuat halaman dokumentasi untuk buat pada modul Scribunto ini.
Penyunting dapat melakukan uji coba pada halaman bak pasir (buat | cermin) dan kasus uji (buat) modul ini.
Subhalaman modul ini.
Penyunting dapat melakukan uji coba pada halaman bak pasir (buat | cermin) dan kasus uji (buat) modul ini.
Subhalaman modul ini.
localp={} functionp.wikidatacheck(frame) localpframe=frame:getParent() localconfig=frame.args-- the arguments passed BY the template, in the wikitext of the template itself localargs=pframe.args-- the arguments passed TO the template, in the wikitext that transcludes the template localproperty=config.property localvalue=config.valueor"" localcatbase=config.category localnamespaces=config.namespaces localnocatsame=config.nocatsameor"" localqid=config.qidor"" localok=false-- one-way flag to check if we're in a good namespace localns=mw.title.getCurrentTitle().namespace forvinmw.text.gsplit(namespaces,",",true)do iftonumber(v)==nsthen ok=true end end ifnotokthen-- not in one of the approved namespaces return"" end localentity ifqid==""then entity=mw.wikibase.getEntityObject() else entity=mw.wikibase.getEntityObject(qid) end ifnotentitythen-- no Wikidata item return"[[Kategori:"..catbase.." tidak ada di Wikidata]]" end ifvalue==""then returnnil-- Using Wikidata end localclaims=entity.claimsor{} localhasProp=claims[property] ifnothasPropthen-- no claim of that property return"[[Kategori:"..catbase.." tidak ada di Wikidata]]"-- bad. Bot needs to add the property end fori,vinipairs(hasProp)do-- Now we try to iterate over all possible values? propValue=(v.mainsnak.datavalueor{}).value ifpropValue==valuethen ifnocatsame==""then return"[[Kategori:"..catbase.." sama seperti Wikidata]]"-- yay! else returnnil-- if nocatsame, the "same as" category is not added end end end return"[[Kategori:"..catbase.." berbeda dengan Wikidata]]"-- needs human review :( end returnp