Modulo:PopolazioneIT: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m nomi variabili standard, fix minori
m modulo no globals obsoleto
 
(15 versioni intermedie di 3 utenti non mostrate)
Riga 1:
--[[
require('Modulo:No globals')
* Modulo che implementa il template PopolazioneIT.
]]--
 
require('strict')
 
local getArgs = require('Modulo:Arguments').getArgs
local cfgmWikidata = mw.loadDatarequire('Modulo:Sandbox/ValterVB/Bilancio/DataWikidata')
local p = {}
 
-- Funzione per l'utilizzo da un altro modulo.
function p.get_abitanti(frame)
function p._main(args)
local args = getArgs(frame)
local data = mw.loadData('Modulo:PopolazioneIT/Data')
local ret
 
-- fonte
if args[1] == 'n' then
local popolazione = cfg.popolazione[args[1]]
return mw.getCurrentFrame():expandTemplate{
if popolazione then
title = "Cita web",
ret = popolazione[1] .. frame:extensionTag{ name = 'ref', content = cfg.nota}
ret args = ''{
[1] = data.urlfonte,
[2] = data.titolofonte,
[3] = data.data
}
}
end
 
-- 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 istatID then
ret = data[istatID]
if popolazioneret then
if args[1] == 'f' then
ret = mw.language.getContentLanguage():formatNum(ret)
end
end
else
ret = ''
end
return ret or ' - '
end
 
-- Funzione per il template {{PopolazioneIT}}.
return ret or ' - '
function p.get_abitantimain(frame)
return p._main(getArgs(frame, { parentOnly = true }))
end