Module:Émâge Wikidata

De Vouiquipèdia, l’enciclopèdia abada.

La documentation pour ce module peut être créée à Module:Émâge Wikidata/doc

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

function p.main(frame) -- mémos arguments que Wikidata + argument "info", betar "émâge" por avêr lo nom du fichiér et "lègenda" por avêr la lègenda
	local infotype = frame.args.info
	local args = frame:getParent().args
	local localdata = args[1] and mw.text.trim(args[1]) or nil -- se de balyês sont aprovisionâyes localament, les empleyér pletout que les balyês de Wikidata
	if localdata and (localdata ~= "") then
		if localdata == "-" then
			return nil
		else
			return localdata
		end
	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 == "émâge" then
		return wd.formatStatement(claim, args)
	end
	if infotype == "lègenda" 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 "frp")) then
				return wd.formatSnak(j, args)
			end
		end
	end
end

return p