Module:User:Justinrleung/wikidata
Appearance
- This module sandbox lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
local export = {}
local function getWikidata(entity, property)
if property == "arabic" then
return mw.wikibase.getLabelByLang(entity, 'ar')
elseif property == "wplink" then
return mw.wikibase.getSitelink(entity, 'enwiki')
elseif property == "coords" then --coordinates
local coords = mw.wikibase.getBestStatements(entity, 'P625')[1]["mainsnak"]["datavalue"]["value"]
local lat = coords["latitude"]
local long = coords["longitude"]
return lat, long
end
end
function export.test()
--local arabic = getWikidata('Q1617666', 'arabic')
local lat, long = getWikidata('Q1617666', 'coords')
--local wplink = getWikidata('Q1617666', 'wplink')
return lat, long
end
return export