Module talk:European and national party data
{{Archives}}
Roadmap: translation
Next steps:
- Start it-wiki
- Try and develop own implementation of calls to Wikidata
class="wikitable centre sortable"
|+ ! rowspan=2 | Task ! colspan=7 | Completion ! rowspan=2 | Comments |
EN
! FR ! DE ! NL ! IT ! ES ! PT |
---|
Tests
| style="text-align: center;" |N/A | style="text-align: center;" |Utilisateur | style="text-align: center;" |Community not interested | style="text-align: center;" |Gebruiker | style="text-align: center;" |Utente | style="text-align: center;" |Usuario | style="text-align: center;" |Usuário | |
Create module, config file
| style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" | | style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" |✅ | |
Create sandbox and testcases
| style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" | | style="text-align: center;" |❌ | style="text-align: center;" |✅ | style="text-align: center;" |❌ | style="text-align: center;" |✅ | |
Create three templates
| style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" | | style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" |✅ | |
Validate module and templates
| style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" | | style="text-align: center;" |❌ | style="text-align: center;" |⚠️ | style="text-align: center;" |❌ | style="text-align: center;" |✅ | |
Translate config file
| style="text-align: center;" |N/A | style="text-align: center;" |✅ | style="text-align: center;" | | style="text-align: center;" |❌ | style="text-align: center;" |✅ | style="text-align: center;" |❌ | style="text-align: center;" |✅ | |
Add untranslated documentation to module
| style="text-align: center;" |N/A | style="text-align: center;" |✅ | style="text-align: center;" | | style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" |✅ | |
Translate module documentation
| style="text-align: center;" |N/A | style="text-align: center;" |✅ | style="text-align: center;" | | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |✅ | |
Add untranslated documentation to templates
| style="text-align: center;" |N/A | style="text-align: center;" |✅ | style="text-align: center;" | | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |✅ | |
Translate template documentation
| style="text-align: center;" |N/A | style="text-align: center;" |✅ | style="text-align: center;" | | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |✅ | |
Add testcases
| style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" | | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |✅ | |
Deploy templates to EUPPs/EUPAs
| style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" | | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |✅ | |
Deploy templates to national parties
| style="text-align: center;" |⚠️ | style="text-align: center;" |⚠️ | style="text-align: center;" | | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |⚠️ | |
| style="text-align: center;" |🏆
| style="text-align: center;" |🏆 | style="text-align: center;" | | style="text-align: center;" | | style="text-align: center;" | | style="text-align: center;" | | style="text-align: center;" |🏆 | |
Roadmap: deployment
class="wikitable centre sortable"
|+ ! rowspan=2 | Task ! colspan=7 | Completion ! rowspan=2 | Comments |
EN
! FR ! DE ! NL ! IT ! ES ! PT |
---|
EUPP article
| style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" |N/A | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |✅ | |
European political parties
| style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" |N/A | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |✅ | |
European political alliances
| style="text-align: center;" |✅ | style="text-align: center;" |✅ | style="text-align: center;" |N/A | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |❌ | style="text-align: center;" |✅ | |
National political parties
| style="text-align: center;" |✅ ALDE | style="text-align: center;" |❌ Main | style="text-align: center;" |N/A | style="text-align: center;" |❌ Main | style="text-align: center;" |❌ Main | style="text-align: center;" |❌ Main | style="text-align: center;" |❌ Main |
|
Other articles
| style="text-align: center;" |✅ European Council | style="text-align: center;" | | style="text-align: center;" |N/A | style="text-align: center;" | | style="text-align: center;" | | style="text-align: center;" | | style="text-align: center;" | | |
| style="text-align: center;" |🏆
| style="text-align: center;" | | style="text-align: center;" | | style="text-align: center;" | | style="text-align: center;" | | style="text-align: center;" | | style="text-align: center;" | | |
Reference files
- Synchronizer: Synchronizer (Q133503746)
- Module
- Module:European and national party data
- Module:European and national party data/testcases
- Module:European and national party data/testcases composition bar
- Module sandbox
- Module:European and national party data/sandbox
- Module:European and national party data/sandbox/testcases
- Module:European and national party data/sandbox/testcases composition bar
- Templates
- Template:EUPP data
- Template:Political party data
- Template:EU institution seats
- Wikidata items
- Module:European and national party data
- Template:EUPP data
- Template:Political party data
- Template:EU institution seats
- Other
- Table mapping national parties to their European party of membership (also used to link a party or member state to its lower and upper houses)
- Module config file
Issues with national party seats in national legislatures
Hey @Trappist the monk, how are you? I am working on the translation of the module to use it across various Wikis, wanna help? I think key will be to find a way to localise the calls to Wikidata.
But a lower-hanging fruit is the case of Portugal, where the calls to wikidata and the composition bar are quite compatible with the English version. As you can see here and here, most tests work. The ones that don't seem to only concern the number of seats of national parties (called with their qIDs in the tests) in national legislatures, which would concern the function npp_seats_and_seat_share_in_national_institutions
. However, I am not quite seeing what could be breaking it. Any ideas? Julius Schwarz (talk) 08:57, 24 April 2025 (UTC)
:Ok, I am thinking that the member state name may be translated. I am going to try and move from using the member state's name to its qID. Julius Schwarz (talk) 09:13, 24 April 2025 (UTC)
::Yes, that was it and I added european_party_qid and member_state_qid to the online table, in order to run checks on qIDs instead of on names. Julius Schwarz (talk) 13:06, 24 April 2025 (UTC)
:A quick look at :de:Modul:Wikidata, :es:Módulo:Wikidata, :fr:Module:Wikidata, :it:Modulo:Wikidata, :nl:Module:Wikidata, :pt:Módulo:Wikidata seems to show that while there may be similarities among them, they do not appear to be the same as en:Module:Wikidata. I suspect that the politics necessary to unify these modules would be a daunting task. Perhaps the better solution is to roll-your-own access to wikidata using the mw.wikibase library. Such documentation as there is for that is at https://doc.wikimedia.org/Wikibase/master/php/docs_topics_lua.html.
:
:Similarly, you might also create a custom lua version of {{tlx|composition bar}} so that you avoid anomalous variations that might crop up at the various wiki language editions.
:—Trappist the monk (talk) 22:18, 24 April 2025 (UTC)
::Thanks @Trappist the monk, I can look into that, but that seems daunting too. I was kind of hoping that with a nice if conditionality on the language, we could spread the arguments as needed based on per-Wiki structures. But I will check your link.
::The composition bar point is probably less feasible, since this template would most likely be sitting next to other composition bars and would therefore really need to look the exact same. Julius Schwarz (talk) 11:31, 25 April 2025 (UTC)
Preventing error message inside composition bar
Hi @Trappist the monk, I have made some good progress on the translation of arguments and parameters, and that should pretty much be ready. Doesn't solve the wikidata/composition bar template implementation issue just yet, but at least I can test deploy to Portuguese Wikipedia (which so far seems to work, see testcases composition bar).
One separate issue that I have is as follows (in the sandbox): when I ask for the number of seats of a party where Wikidata does not have that information, the function returns an error message, as it should. For instance (note: maybe no longer the best error message, but that's a separate issue):
*
-> {{#invoke:European and national party data|main|national_party|seats|Q173152|ep}}
However, when I call the same function to retrieve that number for the purpose of a composition bar, then I should not have that error message returned, and instead just have the composition bar function itself return an error. I have tried to make this work, but no to avail. Any ideas?
-> {{#invoke:European and national party data/sandbox|main|national_party|seat composition bar|Q173152|ep}}{{#invoke:European and national party data/sandbox|main|national_party|seat composition bar|Q173152|ep}}
Julius Schwarz (talk) 12:47, 29 April 2025 (UTC)
:You can have the code that returns the error messages from allpp_seats_in_eu_institutions() return a second value (a boolean) so, at line 457 this (line 459 similar):
::
:Then, change line 740 to this:
::
party_seats, has_error = allpp_seats_in_eu_institutions (frame, party, institution, cfg.body_prop_t[institution]);
if has_error then
return party_seats; --
end
:—Trappist the monk (talk) 13:46, 29 April 2025 (UTC)
::Thanks for the quick feedback, @Trappist the monk. However, I am not sure this is working. I [https://en.wikipedia.org/w/index.php?title=Module%3AEuropean_and_national_party_data%2Fsandbox&diff=1287956962&oldid=1287947887 made the changes], but I am not seeing a change in the testcases page. Did I not do it right? Julius Schwarz (talk) 14:00, 29 April 2025 (UTC)
:::I changed your example above to remove the {{tag|nowiki}} tags and to use the sandbox. Looks like it's working correctly – shows the module's error message, not the MediaWiki error messages. But, your testcases page is calling the live version of the module not the sandbox.
:::—Trappist the monk (talk) 14:20, 29 April 2025 (UTC)
::::Ah yes, indeed. Thanks a lot! Julius Schwarz (talk) 14:30, 29 April 2025 (UTC)
Translation of calls to wd/wikidata and composition_bar templates
Hi @Trappist the monk, so the translation of parameters and arguments now works, and I am just getting to the translation of the calls to wd/wikidata and composition_bar templates. I wrote a xlate_wikidata function in the sandbox and will test it early next week. Would you mind having a quick look to see whether this at least has the possibility of working? That would be helpful. Thanks a lot! Note: the idea is to develop the function in the English wikipedia, to make sure that it does not break anything with the current module, and then to move it to the French Wikipedia to work on adding another language. Julius Schwarz (talk) 14:31, 2 May 2025 (UTC)
:At line 145, you create args_t
. Are you saying that {{tlx|wikidata}} takes a lua sequence as its options positional parameter? Are you sure about that?
:
:Is it your intention to duplicate lines 146–160 for each language?
:
:At line 144, you fetch the local wiki's language tag. That happens 9 other times in the module. Perhaps the best way to do that is to do it only once as an export from the ~/config module. line 146 then becomes:
::
:and line 144 goes away. The other calls to set this_project_language
also go away.
:—Trappist the monk (talk) 18:51, 2 May 2025 (UTC)
::Hey, thanks for the reply! Let me try and address your points in order. 1/ Maybe not, you are right. I was hoping that returning args_t would be akin to return the options one after the other. 2/ Yes, duplicating the lines for each language was kind of my plan. I realise that if we went for an own implementation of the call to Wikidata, as you suggested, we would not need that, but I have no real idea of how to do that (and I still think that wouldn't really work in the case of the composition_bar template, which would still need to look like what the template looks like in each local version). 3/ That's a really good point, I will give that a try. Julius Schwarz (talk) 20:55, 2 May 2025 (UTC)
::Hey @Trappist the monk, I implemented the changes you suggested and went ahead with replacing the use of "frame:expandTemplate" with calls to the new "xlate_wikidata" function, and it just "kinda" works. If you check the regular testcases (not the ones for the composition bar yet), some values work, but some are off. I am having the feeling that the xlate_wikidata function returns the first preferred value for the right entity/property, regardless of the qualifier, which is odd. For instance:
::*
returns 11, which is right, but it is also the first preferred value for seats [https://www.wikidata.org/wiki/Q208242 here];
::*
returns 4, which is false, but it is the first preferred value [https://www.wikidata.org/wiki/Q220945 here], under a different qualifier;
::* same thing when asking about [https://www.wikidata.org/wiki/Q25079 ALDE] and the [https://www.wikidata.org/wiki/Q639383 EFA] returning 5 and 8, respectively.
::This is surprising because these are rather straightforward calls. Any ideas? Julius Schwarz (talk) 07:33, 6 May 2025 (UTC)
:::When you write:
::::
:::xlate_wikidata()
takes that and, at line 154 creates a table for args
that (to lua) looks like this:
::::
[1] = "property",
[2] = "Q208242",
[3] = "P1410",
["qualifier_id"] = "Q8880",
}
:::I suspect that args["qualifier_id"]
is not what you wanted. Rather, did you not want:
::::
[1] = "property",
[2] = "Q208242",
[3] = "P1410",
["P208"] = "Q8880",
}
:::Perhaps, at line 154, you meant to write:
::::
:::—Trappist the monk (talk) 13:58, 6 May 2025 (UTC)
::::I guess I did mean to write that, yes indeed :) Thanks! I will continue trying to address the following issues. Julius Schwarz (talk) 14:39, 6 May 2025 (UTC)
::::Say @Trappist the monk, you have shown how to call a template with frame:expandTemplate ({title='wikidata', args = {....}});
, but how does one call a module? Julius Schwarz (talk) 14:25, 7 May 2025 (UTC)
:::::The module must be callable from another module. For years and years, Module:Citation/CS1 (the engine that renders {{tlx|cite book}}, {{tlx|cite web}}, etc) has not been callable from another module. At its most recent update, Module:Citation/CS1 became callable. {{tlx|cite tweet}} is a template that wraps {{tld|cite web}} by way of Module:Cite tweet which now calls Module:Citation/CS1.
:::::
:::::At the very bottom of Module:Citation/CS1 there are two exported functions. citation
is the entry point for the _citation
is the entry point for use by other modules.
:::::
:::::{{tld|cite tweet}} calls main()
in Module:Cite tweet at line line 103. The code fiddles about collecting and formatting parameter values and stuff until at line 146 it calls _citation
in Module:Citation/CS1 to get a rendered citation.
:::::
:::::Does that answer your question?
:::::—Trappist the monk (talk) 17:07, 7 May 2025 (UTC)
::::::Kind of, yes. Does this mean that Module:Wd is therefore not callable because is does not have that module entry point? Julius Schwarz (talk) 08:40, 8 May 2025 (UTC)
::::Actually, if you have a second to have a look at the xlate_wikidata
function in the French sandbox (see testcases), that would be great! Julius Schwarz (talk) 14:57, 7 May 2025 (UTC)
:::::Did you remember to export this_project_language
from :fr:Module:European and national party data/config? Should the fr.wiki version of that module be the same as the en.wiki version?
:::::—Trappist the monk (talk) 18:58, 7 May 2025 (UTC)
::::::Ahah, damnit, the export again. I should copy/pasted the config from pt instead of just adding bits that were missing. Thanks. As for the module itself, I copied the en-wiki/sandbox version to fr-wiki/sandbox, and am now working there to add the part for fr-wiki. Once that is done, I will move it back to en-wiki and, indeed, all modules will be the same -- just the config file will be different. Julius Schwarz (talk) 20:49, 7 May 2025 (UTC)
::::Quick follow-up questions, @Trappist the monk:
::::* Function test2
calls xlate_wikidata
; it takes a party_qid and a property and should return the qID of the response. On :fr:Utilisateur:Julius Schwarz/Brouillon, you see that the template gives out the right output, but test2
does not. Instead it display "displayformat = raw", which should just be sent to the
template. Any idea why?
::::* In xlate_wikidata
, we do a check to see whether value_of_qualifier
is nil
or not. However, even when it is nil
(as, for instance, it is in the test2
function), it still seem considered as not nil
(like if you change the return value in the if nil ~= value_of_qualifier
case, this is what will be returned by test2
). Any idea why?
::::Julius Schwarz (talk) 11:49, 8 May 2025 (UTC)
:::::The call in test2()
looks like this:
::::::
:::::Replace line 181 with:
::::::
:::::Then, in line 186, replace local_raw
with ['displayformat'] = local_raw
; similar replacements in the other template expansions.
:::::
:::::Empty string is not the same as nil
. In the call in test2()
, the sixth parameter, value_of_qualifier
, is set to empty string. If you want that value to be nil
, you must explicitly set it to nil
:
::::::
:::::—Trappist the monk (talk) 14:58, 8 May 2025 (UTC)
Own implementation
Hey @Trappist the monk, I just finished rolling out the French version, and am starting the Italian one, so things are moving forward. Say, in a previous question, you had opined that, since templates were different from wiki to wiki, maybe the better solution would be to roll-our-own access to wikidata using the mw.wikibase library.
While I continue to think that this should not apply to the composition_bar templates (so that we keep wikis' respective look and feel) and that doing this for the wikidata templates is above my competencies, I do agree that this would make things easier in the longer run -- for instance, the different implementation in fr-wiki means that several options (reference, width, bar-color, etc.) are not available, which is unfortunate. So I was wondering: is this something that you might consider doing? I would be really useful help! Julius Schwarz (talk) 15:12, 13 May 2025 (UTC)
:Yep, I did, but I think that I meant that suggestion as something for {{em|you}} to do; I don't think that I was volunteering to do it. I don't know much about wikidata and, for me, wikidata isn't all that interesting because it isn't used in my normal areas of interest (with the exception of {{tlx|cite q}} which I will tweak when I have to but otherwise prefer to ignore).
:—Trappist the monk (talk) 19:09, 15 May 2025 (UTC)
::Ahah, don't worry, I did understand that that was a suggestion for me to do -- I was just wondering whether you actually might consider making an exception and volunteerting in the end. I just realise that the obstacles to fully implementing the module are too numerous for the translation system (it does work, but I have to leave some functionalities aside, which is a shame), but I wouldn't even know where to begin with this.. Julius Schwarz (talk) 06:51, 16 May 2025 (UTC)
:::so what do you think, @Trappist the monk, is that something we could work on in the end? Or would you happy to know someone with the skill/time to help out on this? Julius Schwarz (talk) 10:17, 19 May 2025 (UTC)