Módulo:Infobox/Funções/Localidade

Permanently protected module
Origem: Wikipédia, a enciclopédia livre.
Documentação do módulo[ver] [editar] [histórico] [purgar]

Descrição

Este módulo tem funções auxiliares para criar infocaixas

Uso

Outra documentação:

-- Funcões utilizadas pelo módulo:Infobox/Localidade
local l = {}
local localdata = require( 'Módulo:Infobox/Localdata' )
local wikidata = require "Módulo:Infobox/Wikidata"
local general = require "Módulo:Infobox/Funções"

function l.mainimage()
    local defaultimage = 'Padrao 2.svg' -- demande d'illustration si pas d'illustration
    return  general.mainimage('!Subdivisão administrativa ilustrada por padrao.svg', defaultimage)
end

function l.populacao()
    local title = 'população'

    local rows
    if localdata['população'] then
        return {type = 'row',  label = title, value = 'população'}
    end
    
    local statements = wikidata.getClaims{
        entity = localdata.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 ano = wikidata.getFormattedQualifiers(statement, {'P585'})
        if annee then
            text = text .. ' <small>(' .. ano .. ')</small>'
        end
        text = text .. '<br />'
    end
    return {type = 'row', label = 'População', value = function() return text end}
end
return l