Módulo:Imagem Wikidata

local p = {}local wd = require "Módulo:Infobox/Wikidata"function p.main(frame) -- mesmos argumentos que Wikidata + argumento "info",        -- mete "imagem" para ter o nome do ficheiro e "legenda" para legenda    local infotype = frame.args.info    local args = frame:getParent().args    local localdata = args[1] -- se os dados são fornecidos localmente    -- os utilizadores não querem os dados do 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" or infotype == "imagem" then        return wikidata.formatStatement(claim, args)    end    if infotype == "legenda" or infotype == "caption" 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 "pt")) then                return wd.formatSnak(j, args)            end        end    endendreturn p