Modulo:PopolazioneIT: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
upd
m modulo no globals obsoleto
 
(22 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(frame)
local tmWikidata = getArgsrequire(frame'Modulo:Wikidata')
local istat_codep = t[1]{}
 
if istat_code == nil then return '' end
-- Funzione per l'utilizzo da un altro modulo.
local popolazione = lg.popolazione[istat_code]
function p._main(args)
local source = lg.nota
local lgdata = mw.loadData( 'Modulo:Sandbox/ValterVB/BilancioPopolazioneIT/Data');
if popolazione then
 
return popolazione[1]+source
-- 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 data.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 bilanciop.get_abitantimain(frame)
return p._main(getArgs(frame, { parentOnly = true }))
end
 
return bilanciop