Module:European and national party data/config
Apparence
La documentation de ce module est générée par le modèle {{Documentation module}}.
Les éditeurs peuvent travailler dans le bac à sable (créer).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
--[[--------------------------< S E T T I N G S >--------------------------------------------------------------
settings definitions for i18n; translate only the rvalues
]]
local settings_t = {
template_name = 'Données des partis européens et nationaux', -- name of the template that #invokes this module
err_category = 'Articles avec erreurs sur les données des partis européens et nationaux', -- name of category that lists article with EUPP seats errors
help = 'aide' -- 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 = "module pas appelé depuis la page d'un parti politique européen", -- misapplied 'thisparty' keyword
inst_unknown_party = 'institution $1 a un parti inconnu: $2', -- $1 is institution; $2 is party
missing_inst = 'institution requise', -- first positional parameter is always required
party_req = 'parti requis', -- for those cases when party is missing when required
party_req_share = 'parti requis', -- for those cases when party is missing when required because share is called
ind_only_euco = 'le paramêtre IND est seulement disponible pour EUCO',
all_none_unavailable = "le paramêtre $1 n'est pas disponible pour les législatures nationales",
unknown_inst = 'institution inconnue: $1', -- $1 is content of first positional parameter (should be institution abbrev)
unknown_party = 'parti inconnu : $1', -- $1 is content of second positional parameter (should be party abbrev)
unknown_house_type = 'type de chambre inconnu : $1', -- $1 is content of second positional parameter (should be accepted house types)
unknown_param = 'paramêtre inconnu : $1', -- $1 is content of third positional parameter; not '%' or 'share'
parameter_invalid = 'paramêtre invalide : $1',
percentage_invalid = 'pourcentage invalide : $1', -- $1 is content of fourth positional parameter; not 'yes' or 'pc=yes'
reference_invalid = 'référence invalide : $1', -- $1 is content of fifth positional parameter; not 'yes' or 'ref=yes'
no_qid = 'pas sans qID Wikidata', -- if no qID
not_a_member_party = "pas appelé depuis la page d'un parti membre d'un parti politique européen ; voir https://www.wikidata.org/wiki/$1", --if qid but not listed in table
no_data = 'pas de données Wikidata disponibles pour $2 ; voir https://www.wikidata.org/wiki/$1', --if no data
no_data_short = 'pas de données disponibles sur Wikidata', --if no data
not_member_state = "ce qID n'appartient pas à un état-membre ou il n'existe pas de données sur Wikidata ; voir https://www.wikidata.org/wiki/$1", --if not member state qID or no data
no_country = "aucun pays n'est associé à ce qID ; voir https://www.wikidata.org/wiki/$1", --if not member state qID or no data
unknown_data_type = 'type de données inconnu: $1',
not_valid_eupp_parameter = 'parti européen ou paramêtre non valide : $1',
not_valid_npp = 'parti national non valide : $1',
unknown_party_type = 'type de parti inconnu : $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
}
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'
}
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).
Rule of thumb: arguments use spaces, parameters use hyphens.
]]
local this_project_language = mw.language.getContentLanguage():getCode(); -- get local language
local xlate_t = {
fr = { -- translations for French (fr)
-- party type
entite_europeenne = 'european_entity',
parti_national = 'national_party',
-- data type
sieges = 'seats',
["part des sieges"] = 'seat share',
["barre de composition des sieges"] = 'seat composition bar',
acronyme = 'acronym',
couleur = 'color',
pays = 'country',
["date de fondation"] = 'foundation date',
["membres individuels"] = 'individual members',
["date membres individuels"] = 'individual members date',
label = 'label',
["nom officiel"] = 'official name',
["groupe parlementaire"] = 'parliamentary group',
["financement public"] = 'public funding',
["site web"] = 'website',
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
PGE = '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
PATRIOTES = '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',
TOUS = 'ALL',
AUCUN = 'NONE',
CEPARTI = 'THISPARTY',
-- yes
oui = 'yes',
-- institutions
CER = 'COR',
CE = 'EC',
PE = 'EP', -- European Parliament; translated from fr language to default (en)
EUCO = 'EUCO',
["CHAMBRE-BASSE"] = 'LOWER_HOUSE',
["CHAMBRE-HAUTE"] = 'UPPER_HOUSE',
-- extra parameters
reference = 'reference',
circonscription = 'constituency',
largeur = 'width',
pourcent = 'percent',
["couleur-de-barre"] = 'bar-color',
["couleur-de-fond"] = 'background-color',
bordure = 'border',
verbose = 'verbose',
},
}
local xlate_param_t = {
fr = { -- translations for French (fr)
-- extra parameters
reference = 'reference',
constituency = 'circonscription',
width = 'largeur',
percent = 'pourcent',
["bar-color"] = 'couleur-da-barre',
["background-color"] = 'couleur-de-fond',
border = 'bordure',
verbose = 'verbose',
},
}
--[[--------------------------< 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();
}