Module:Wikidata
ꠍꠥꠞꠔ ꠢꠣꠟ
Documentation for this module may be created at Module:Wikidata/doc
local p = {}
-- Function to fetch Wikidata values
function p.getValue(propertyID, entityID)
local wd = mw.wikibase.getEntity(entityID)
if wd then
local claim = wd:findClaim(propertyID)
if claim then
local value = claim.mainsnak.datavalue.value
if type(value) == "table" and value.amount then
return value.amount
else
return value
end
end
end
return nil
end
-- Function to fetch Wikidata labels
function p.getLabel(entityID, lang)
local wd = mw.wikibase.getEntity(entityID)
if wd then
return wd:getLabel(lang)
end
return nil
end
return p