Modulo:PopolazioneIT: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
.
m modulo no globals obsoleto
 
(41 versioni intermedie di 4 utenti non mostrate)
Riga 1:
--[[
local bilancio = {}
* Modulo che implementa il template PopolazioneIT.
]]--
 
local getArgs = require('Module:Argumentsstrict').getArgs
local lg = mw.loadData( 'Modulo:Sandbox/ValterVB/Bilancio/Data');
 
local getArgs = require('Modulo:Arguments').getArgs
function bilancio.get_abitanti(istat_code)
local mWikidata = require('Modulo:Wikidata')
if code == nil then return '' end
local codep = mw.ustring.lower(code){}
 
if lg.popolazione[code] then code = lg.popolazione[code] end
-- Funzione per l'utilizzo da un altro modulo.
popolazione = lg.popolazione[code]
function p._main(args)
if popolazione then
local lgdata = mw.loadData( 'Modulo:Sandbox/ValterVB/BilancioPopolazioneIT/Data');
return popolazione
 
-- fonte
if args[1] == 'n' then
return mw.getCurrentFrame():expandTemplate{
title = "Cita web",
args = {
[1] = data.urlfonte,
[2] = data.titolofonte,
[3] = data.data
}
}
end
 
return ''
-- data
if args[1] == 'd' then
return popolazionedata.data
end
 
-- valore, puro o con formatnum
local ret
local istatID = args.istatID or mWikidata._getProperty({ 'P635', from = args.from, n = 1 })
if popolazioneistatID then
ret = data[istatID]
if ret then
if args[1] == 'f' then
ret = mw.language.getContentLanguage():formatNum(ret)
end
end
end
return ''ret
end
 
-- Funzione per il template {{PopolazioneIT}}.
function p.main(frame)
return p._main(getArgs(frame, { parentOnly = true }))
end
 
return bilanciop