Module:User:Justinrleung/wikidata

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This is a private module sandbox of Justinrleung, for his own experimentation. Items in this module may be added and removed at Justinrleung's discretion; do not rely on this module's stability.


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