Modulo:Codice statistico/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Nuova sandbox
 
aggiornato alla versione corrente
Riga 10:
local p = {}
 
-- Funzione di formattazione del codice municipale austriaco (Statistik Austria)
local function formatP439formatSA(id)
local formatted_id = string.gsub(id, "(%d%d)(%d)(%d%d)(%d%d%d)", "%1 %2 %3 %4")
return string.format('[http://www.statistik-portal.de/Statistik-Portal/gemeindeverz.asp?G=%s %s]', id, formatted_id)
end
 
local function formatP964(id)
local formatted_id = string.gsub(id, "(%d)(%d%d)(%d%d)", "%1 %2 %3")
return string.format('[http://www.statistik.at/blickgem/gemDetail.do?gemnr=%s %s]', id, formatted_id)
end
 
-- Funzione di formattazione del codice municipale tedesco (Statistisches Bundesamt)
local codes = {
local function formatP964formatDestatis(id)
AUT = { prop = 'P964', catprefix = 'Codice municipale austriaco', format = formatP964 },
local formatted_id = string.gsub(id, "(%d%d)(%d)(%d%d)(%d%d%d)", "%1 %2 %3 %4")
return string.format('[http://www.statistik-portal.de/Statistik-Portal/gemeindeverz.asp?G=%s %s]', id, formatted_id)
end
 
-- Codici statistici configurati
local codesstatCodes = {
AUT = { prop = 'P964', catprefix = 'Codice municipale austriaco', format = formatP964formatSA },
CHE = { prop = 'P771', catprefix = 'Codice OFS' },
DEU = { prop = 'P439', catprefix = 'Codice municipale tedesco', format = formatP439formatDestatis },
ESP = { prop = 'P772', catprefix = 'Codice INE' },
FRA = { prop = 'P374', catprefix = 'Codice INSEE' },
Riga 36 ⟶ 39:
cat = string.format('%s assente su Wikidata', code.catprefix)
elseif wdval == userval then
cat = code.catuguali and string.format('%s uguale a Wikidata', code.catprefix)
else
cat = string.format('%s differente da Wikidata', code.catprefix)
end
elseif wdval then
Riga 56 ⟶ 59:
-- ricerca paese
if args.iso3166 then
code = codesstatCodes[args.iso3166]
end
if not code then
local iso3166 = mWikidata._getProperty({ 'P17', showprop = 'P298', from = args.from, n = 1 }) or {}
code = codesstatCodes[iso3166]
end
 
-- valore letto da Wikidata
if code then
-- valore letto da Wikidata
wdval = mWikidata._getProperty({ code.prop, from = args.from, n = 1 }) or {}
formatted_wdval = (wdval and code.format) and code.format(wdval) or wdval
formatted_userval = (userval and code.format) and code.format(string.gsub(userval, ' ', '')) or userval
end
 
-- categoria di servizio
if mw.title.getCurrentTitle().namespace == 0 and (userval or wdval) then
cat = getWikidataCategory(userval, wdval, code)
end
end