Module:Infobox/Fonctions/Localité/Bac à sable

Une page de Wikipédia, l'encyclopédie libre.

 Documentation[voir] [modifier] [historique] [purger]

Cette page définit un module d'infobox.


-- Functions utilisées par le module:Infobox/Localité
local l = {}
local wikidata = require "Module:Interface Wikidata".fromLua
local general = require "Module:Infobox/Fonctions"
local datemodule = require "Module:Date"
local linguistic = require "Module:Linguistique"

function l.mainimage()
	local defaultimage = 'Defaut 2.svg' -- demande d'illustration si pas d'illustration
	return  general.mainimage('Subdivision administrative illustrée par defaut.svg', defaultimage)
end
            
function l.population()
	local title = 'population'

	local rows
	if localdata['population'] then
		return {type = 'row',  label = title, value = 'population'}
	end
	
	local statements = wikidata.getClaims{entity =item, property= 'P1082', rank = 'best', conjtype= ' ou ', sorttype = inverted, numval = 1}
	if not statements then
		return nil
	end
		
	local text = ''
	for i, statement in pairs(statements) do
		local mainstr = wikidata.formatStatement(statement, {showqualifiers = {}})
		text = text .. mainstr .. ' hab.'
		local annee = wikidata.getFormattedQualifiers(statement, {'P585'})
		if annee then
			text = text .. ' (en ' .. annee .. ')'
		end
		text = text .. '<br />'
	end
	return {type = 'row', label = 'Population', value = function() return text end}
end

return l