--[[--------------------------< S E T T I N G S >--------------------------------------------------------------
settings definitions for i18n; translate only the rvalues
]]
local settings_t = {
template_name = 'European and national party data', -- name of the template that #invokes this module
err_category = 'Articoli con European and national party data errori', -- name of category that lists article with EUPP seats errors
help = 'aiuto' -- help link display text for error messages
}
--[[--------------------------< E R R O R _ M E S S A G E S _ T >----------------------------------------------
error message definitions for i18n; translate only the rvalues
]]
local error_messages_t = {
thisparty = 'non chiamato dalla pagina di un partito europeo', -- misapplied 'thisparty' keyword
inst_unknown_party = 'istituzione $1 ha un partito sconosciuto: $2', -- $1 is institution; $2 is party
missing_inst = 'istituzione necessaria', -- first positional parameter is always required
party_req = 'partito necessario', -- for those cases when party is missing when required
party_req_share = 'partito necessario', -- for those cases when party is missing when required because share is called
ind_only_euco = 'il parametro IND è disponibile solo per EUCO',
all_none_unavailable = 'il parametro $1 non è disponibile per le legislature nazionali',
unknown_inst = 'istituzione sconosciuta: $1', -- $1 is content of first positional parameter (should be institution abbrev)
unknown_party = 'partito sconosciuto: $1', -- $1 is content of second positional parameter (should be party abbrev)
unknown_house_type = 'tipo de camera sconosciuto: $1', -- $1 is content of second positional parameter (should be accepted house types)
unknown_param = 'parametro sconosciuto: $1', -- $1 is content of third positional parameter; not '%' or 'share'
parameter_invalid = 'parametro invalido: $1',
percentage_invalid = 'percentuale invalido: $1', -- $1 is content of fourth positional parameter; not 'yes' or 'pc=yes'
reference_invalid = 'referenza invalida: $1', -- $1 is content of fifth positional parameter; not 'yes' or 'ref=yes'
no_qid = 'la pagina non ha un qID di Wikidata', -- if no qID
not_a_member_party = 'non chiamato dalla pagina di un partito membro di un partito politico europeo, see https://www.wikidata.org/wiki/$1', --if qid but not listed in table
no_data = 'nessun dato disponibile su Wikidata per $2; see https://www.wikidata.org/wiki/$1', --if no data
no_data_short = 'nessun dato disponibile su Wikidata', --if no data
not_member_state = 'il qID non appartiene a uno stato membro o non ci sono dati disponibili su Wikidata, see https://www.wikidata.org/wiki/$1', --if not member state qID or no data
no_country = 'nessun paese è associato a questo qID, see https://www.wikidata.org/wiki/$1', --if not member state qID or no data
unknown_data_type = 'tipo di dati sconosciuto: $1',
not_valid_eupp_parameter = 'partito europeo o parametro non valido: $1',
not_valid_npp = 'partito nazionale non valido: $1',
unknown_party_type = 'tipo di partito sconosciuto: $1'
}
--[[--------------------------< W I K I D A T A M A P P I N G >----------------------------------------------
do not translate these. These tables map abbreviations use in the template/module call to wikidata qids
]]
local institutions_t = { -- map institution abbreviation to wikidata qid
COR = 'Q205203', -- European Committee of the Regions
EC = 'Q8880', -- European Commission
EP = 'Q8889', -- European Parliament
EUCO = 'Q8886', -- European Council
PACE = 'Q939743' -- Parliamentary Assembly of the Council of Europe
}
local parties_t = { -- map party abbreviation to wikidata qid
ALDE = 'Q25079', -- Alliance of Liberals and Democrats for Europe Party
ECPP = 'Q1377279', -- European Christian Political Party
ECR = 'Q1577483', -- European Conservatives and Reformists
EDP = 'Q734792', -- European Democratic Party
EFA = 'Q639383', -- European Free Alliance
EGP = 'Q950179', -- European Green Party
EL = 'Q202649', -- Party of the European Left
ELA = 'Q130219314', -- European Left Alliance for the People and the Planet
EPP = 'Q208242', -- European People's Party
ESN = 'Q130269264', -- Europe of Sovereign Nations
PATRIOTS = 'Q18907386', -- Patriots.eu
PES = 'Q220945' -- Party of European Socialists
}
local alliances_t = { -- map alliances abbreviation to wikidata qid
VOLT = 'Q55229798', -- Volt Europa
DIEM25 = 'Q22674451', -- Democracy in Movement 2025
PPEU = 'Q15081858', -- European Pirate Party
APEU = 'Q22079847', -- Animal Politics EU
ECA = 'Q123785828', -- European Communist Action
}
local misc_parties_t = {
IND = 'Q327591', -- independent politicians on the European Council
}
local body_prop_t = {
COR = 'P194', -- legislative body
EC = 'P208', -- executive body
EP = 'P194',
EUCO = 'P208',
PACE = 'P194'
}
local data_prop_t = {
acronym = 'P1813', --short name
colour = 'P465', --hex colour
country = 'P17',
foundation_date = 'P571', --inception date
individual_members = 'P2124', --member country
official_name = 'P1448',
parliamentary_group = 'P4100',
public_funding = 'P12919',
website = 'P856'
}
--[[--------------------------< K E Y W O R D S >--------------------------------------------------------------
do not translate these. this table lists all known keywords that may appear in the party (2nd) positional parameter
]]
local keywords_t = {
ALL = true, -- seats of all European parties combined
NONE = true, -- seats not occupied by European parties
THISPARTY = true, -- for use when module is called from the page of a European party
}
local keywords_lower_upper_t = {
ALL = true, -- seats of all European parties combined
THISPARTY = true, -- for use when module is called from the page of a European party
}
local national_institutions_t = {
LOWER_HOUSE = true,
UPPER_HOUSE = true,
}
--[[--------------------------< T R A N S L A T I O N >--------------------------------------------------
translate these (except this_project_language).
]]
local this_project_language = mw.language.getContentLanguage():getCode(); -- get local language
local xlate_t = {
it = { -- translations for Italian (it)
-- party type
entita_europea = 'european_entity',
partito_nazionale = 'national_party',
-- data type
seggi = 'seats',
quota_di_seggi = 'seat share',
barra_di_composizione_di_seggi = 'seat composition bar',
acronimo = 'acronym',
colore = 'color',
paese = 'country',
data_fondazione = 'foundation date',
anno_fondazione = 'foundation year',
membri_individuali = 'individual members',
data_membri_individuali = 'individual members date',
anno_membri_individuali = 'individual members year',
etichetta = 'label',
nome_ufficiale = 'official name',
gruppo_parlamentare = 'parliamentary group',
finanziamento_pubblico = 'public funding',
sito_web = 'website',
-- European political parties and alliances
ALDE = 'ALDE', -- Alliance of Liberals and Democrats for Europe Party
PPCE = 'ECPP', -- European Christian Political Party
CRE = 'ECR', -- European Conservatives and Reformists
PDE = 'EDP', -- European Democratic Party
ALE = 'EFA', -- European Free Alliance
PVE = 'EGP', -- European Green Party
SE = 'EL', -- Party of the European Left
ELA = 'ELA', -- European Left Alliance for the People and the Planet
PPE = 'EPP', -- European People's Party
ESN = 'ESN', -- Europe of Sovereign Nations
PATRIOTS = 'PATRIOTS', -- Patriots.eu
PSE = 'PES',
VOLT = 'VOLT', -- Volt Europa
DIEM25 = 'DIEM25', -- Democracy in Movement 2025
PPEU = 'PPEU', -- European Pirate Party
APEU = 'APEU', -- Animal Politics EU
ECA = 'ECA', -- European Communist Action
-- special parameters
IND = 'IND',
TUTTI = 'ALL',
NESSUNO = 'NONE',
QUESTOPARTITO = 'THISPARTY',
-- yes
si = 'yes',
-- institutions
CDR = 'COR',
CE = 'EC',
PE = 'EP', -- European Parliament; translated from pt language to default (en)
EUCO = 'EUCO',
APCE = 'PACE',
["CAMERA-BASSA"] = 'LOWER_HOUSE',
["CAMERA-ALTA"] = 'UPPER_HOUSE',
-- extra parameters
referenza = 'reference',
circoscrizione = 'constituency',
larghezza = 'width',
["per-cento"] = 'percent',
["colore-barra"] = 'bar-color',
["colore-di-sfondo"] = 'background-color',
bordo = 'border',
numero1 = 'num1',
barra = 'bar',
numero2 = 'num2',
verboso = 'verbose',
},
}
local xlate_param_t = {
it = { -- translations for Italian (it)
-- extra parameters
reference = 'referenza',
constituency = 'circoscrizione',
width = 'larghezza',
percent = 'per-cento',
["bar-color"] = 'colore-barra',
["background-color"] = 'colore-di-sfondo',
border = 'bordo',
num1 = 'numero1',
bar = 'barra',
num2 = 'numero2',
verbose = 'verboso',
Y = 'A', -- for formatDate year
},
}
--[[--------------------------< B U I L D _ T A B _ D A T A >--------------------------------------------------
this module uses tabular data files from commons. This function builds a sequence of associative tables for
the tabular data file named in <file_name>.
this function extracts two 'sections' from the tabular data files: column names and row data. Every row data
item is indexed by the associated column name
]]
local function build_tab_data (file_name)
local data_raw_t = mw.ext.data.get (file_name); -- get the tabular data from <file_name>
local column_heads_t = data_raw_t.schema.fields; -- point to the column headings sequence
local rows_t = data_raw_t.data; -- point to the data sequence
local out_data_t = {};
for _, row_t in ipairs (rows_t) do -- for each data row in the <rows_t> sequence
local row_data_t = {}; -- make a new associative table of row with column headings as indexes
for i=1, #column_heads_t do -- done this way because some data cells in <data_raw_t> may be nil (which would stop ipairs() loop)
row_data_t[column_heads_t[i].name] = row_t[i]; -- make a table entry
end
row_data_t.european_party = row_data_t.european_party:upper(); -- ensure <european_party> values are always uppercase
table.insert (out_data_t, row_data_t); -- done; add this table to the output sequence
end
return out_data_t; -- all data added; done
end
local tab_data_t = build_tab_data ('Mapping of national parties members of European parties to lower and upper houses.tab');
--[[--------------------------< E X T R A C T _ M S _ D A T A >------------------------------------------------
extracts member state upper/lower house names and associated qids from <tab_data_t>
Source data has multiple copies of the required data; we'll take only on copy of each.
]]
local function extract_ms_data ()
local raw_data_t = {}; -- raw, unordered data go here
for i, row_t in ipairs (tab_data_t) do -- for each row in the source data
if not raw_data_t[row_t.member_state] then -- if the source data are already in <raw_data_t> then skip to the next source data row
raw_data_t[row_t.member_state] = { -- otherwise add these data from the current source data row
member_state = row_t.member_state,
member_state_qid = row_t.member_state_qid,
lower_house = row_t.lower_house,
lower_house_qid = row_t.lower_house_qid,
upper_house = row_t.upper_house,
upper_house_qid = row_t.upper_house_qid
};
end
end
local out_data_t = {}; -- final output will go here
for ms, house_data_t in pairs (raw_data_t) do -- create a sortable sequence
table.insert (out_data_t, house_data_t);
end
table.sort (out_data_t, function (a_t, b_t) -- custom ascending sort on member state name
return a_t.member_state < b_t.member_state;
end
);
return out_data_t; -- and done
end
--[[--------------------------< I N V E R T _ Q I D _ M A P >--------------------------------------------------
invert the contents of <in_data_t> so that qid indexes (maps to) the abbreviation; used to invert <parties_t>
and <aliances_t>
]]
local function invert_qid_map (in_data_t)
local out_data_t = {}; -- inverted data go here
for p, q in pairs (in_data_t) do -- for each party/qid pair in <parties_t> table
out_data_t[q] = p; -- swap party/qid to qid/party into <out_data_t> table
end
return out_data_t; -- all done
end
--[[--------------------------< E X P O R T S >----------------------------------------------------------------
]]
return {
error_messages_t = error_messages_t, -- these are translatable
settings_t = settings_t,
alliances_t = alliances_t, -- these must not be translated
body_prop_t = body_prop_t,
data_prop_t = data_prop_t,
institutions_t = institutions_t,
keywords_t = keywords_t,
keywords_lower_upper_t = keywords_lower_upper_t,
national_institutions_t = national_institutions_t,
misc_parties_t = misc_parties_t,
parties_t = parties_t,
rev_parties_t = invert_qid_map (parties_t),
rev_alliances_t = invert_qid_map (alliances_t),
this_project_language = this_project_language,
xlate_t = xlate_t,
xlate_param_t = xlate_param_t,
tab_data_t = tab_data_t;
ms_data_t = extract_ms_data();
}