Modulo:European and national party data/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Test xlate_comp referring to Seggi
import from en-wiki sandbox following addition of "year" functions
Riga 157:
 
local function xlate_wikidata (data_requested, qid, property_id, qualifier_id, value_of_qualifier, reference, preferred, raw, linked)
mw.logObject( {data_requested, qid, property_id, qualifier_id, value_of_qualifier, reference, preferred, raw, linked}, "xlate_wikidata()" )
local local_reference = reference;
local local_preferred = preferred;
Riga 173 ⟶ 174:
table.insert(wdargs, 5, qid)
end
if '' ~= qualifier_id andthen
if '' ~= value_of_qualifier then
wdargs[qualifier_id] = value_of_qualifier;
else
table.insert(wdargs, qualifier_id)
end
end
mw.logObject( wdargs, "wdargs" )
return Wd['_' .. data_requested](wdargs);
end
Riga 197 ⟶ 202:
 
local function xlate_composition_bar (frame, seats, total_seats, color, width, percentage, background_color, border)
if 'en' == cfg.this_project_language or 'ptfr' == cfg.this_project_language then
return frame:expandTemplate ({title='Infobox Parti politique/Sièges', args = {seats, total_seats, ['hex'] = color}});
elseif 'it' == cfg.this_project_language then
return frame:expandTemplate ({title='Seggi', args = {seats, total_seats, ['c'] = color}});
elseif 'fres' == cfg.this_project_language then
return frame:expandTemplate ({title='wikidataComposition bar', args = {["entity"] = partyseats, cfg.data_prop_t.website, ['link'] = "-"total_seats, ['numvalhex'] = 1color}});
elseif 'nl' == cfg.this_project_language then
local comp_bar_args_t = {
seats,
total_seats,
color,
width=width,
per=percentage,
['background-color'] = background_color,
border = border,
};
return frame:expandTemplate ({title='Percentagebalk', args = comp_bar_args_t});
else -- for all other languages the assumption is that the template is called composition bar
local comp_bar_args_t = {
seats,
Riga 208 ⟶ 230:
};
return frame:expandTemplate ({title='Composition bar', args = comp_bar_args_t});
elseif 'fr' == cfg.this_project_language then
return frame:expandTemplate ({title='Infobox Parti politique/Sièges', args = {seats, total_seats, ['hex'] = color}});
elseif 'it' == cfg.this_project_language then
return frame:expandTemplate ({title='Seggi', args = {seats, total_seats, ['c'] = color}});
end
end
Riga 324 ⟶ 342:
elseif property_id == "individual members date" then -- special case
if not party then
data = xlate_wikidata ('qualifier', '', 'P2124', 'P585', P585'', 'reference=no', 'preferred=yes', 'raw=no', 'linked=no');
else
data = xlate_wikidata ('qualifier', party_qid, 'P2124', 'P585', 'P585', 'reference=no', 'preferred=yes', 'raw=no', 'linked=no');
end
else -- for all other cases
Riga 1 048 ⟶ 1 066:
elseif data_type == "foundation date" then
return allpp_get_data (frame, party, cfg.data_prop_t.foundation_date);
elseif data_type == "foundation year" then
-- return string.match (allpp_get_data (frame, party_qidparty, cfg.data_prop_t.countryfoundation_date), 'raw-noref%d%d%d%d');
elseif data_type == "individual members" then
return allpp_get_data (frame, party, cfg.data_prop_t.individual_members);
elseif data_type == "individual members date" then
return allpp_get_data (frame, party, 'individual members date');
elseif data_type == "individual members year" then
return string.match (allpp_get_data (frame, party, 'individual members date'), '%d%d%d%d');
elseif data_type == "label" then
return allpp_get_data (frame, party, 'label');
Riga 1 171 ⟶ 1 193:
 
local function test2 (frame)
return cfg.this_project_language;
local args_t = get_args (frame);
local party = args_t[1] and args_t[1]:upper(); -- force to upper case
--if local_reference == 'reference=yes' then local_reference = 'reference' elseif local_reference == 'references=yes' then local_reference = 'references' else local_reference = '' end;
--if local_preferred == 'preferred=yes' then local_preferred = 'preferred' else local_preferred = '' end;
local local_raw = '';
local local_linked = '-';
--local qid = args_t[1];
--local property = args_t[2];
--return allpp_get_data (frame, party_qid, cfg.data_prop_t.country, 'raw-noref');
--return tostring(xlate_wikidata ('property', party, cfg.data_prop_t.website, '', '', 'reference=no', 'preferred=no', 'raw=no', 'linked=no'));
return frame:expandTemplate ({title='wikidata', args = {["entity"] = party, cfg.data_prop_t.website, ['link'] = "-", ['numval'] = 1}});
end
 
Riga 1 193 ⟶ 1 205:
test2 = test2,
test_wikidata_entries = test_wikidata_entries,
-- xlate_wikidata = xlate_wikidata
}