Module:Image Wikidata : Différence entre versions

De louiki
Sauter à la navigation Sauter à la recherche
(ce)
 
m (1 révision importée)
 
(Aucune différence)

Version actuelle datée du 8 février 2019 à 10:40

local p = {} local wd = require "Module:Wikidata"

function p.main(frame) -- mêmes arguments que Wikidata + argument "info", mettre "image" pour avoir le nom du fichier et "légende" pour avoir la légende local infotype = frame.args.info local args = frame:getParent().args local localdata = args[1] -- si des données sont fournies localement, les utiliser plutôt que les données de Wikidata if localdata and (localdata ~= "") then return localdata end args.numval = 1 if (not args.property) or (args.property == "") then args.property = "P18" end local claims = wd.getClaims(args) if not claims then return nil end local claim = claims[1] if infotype == "image" then return wikidata.formatStatement(claim, args) end if infotype == "légende" then local captions = wd.getQualifiers(claim, {"P2096"}, args) if not captions then return nil end for i, j in pairs(captions) do if j.datavalue.value and (j.datavalue.value.language == (args.lang or "fr")) then return wd.formatSnak(j, args) end end end end

return p