Jump to content

Module talk:Political party/Archive 1

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Primefac (talk | contribs) at 10:19, 1 December 2021 (archive some stuff). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Archive 1Archive 2Archive 3Archive 4

Broad strokes of setup

  1. Create module subtemplates  Done
    1. Get a list of all /shortname, /color, and /abbrev pages  Done
      1. Get a list of all /shading pages  Done
    2. Get the content of the templates in #1.  Done
    3. Split by alphabet group  Done
    4. Convert each name/shortname/color/abbrev group into a Lua-fied grouping (see Module:Political party/L)  Done
    5. Add in duplicate names  Done
      1. Duplicate entries in the non-redirect list  Done
      2. Redirects  Done
    6. Remove completely unused templates/parties
      1. Redirects  Done
      2. Primary templates checkmark Semi-done
    7. Add testcases/visual display of colours (on /doc, per places like Module:Sports color)  Done
  2. Convert template usage
    1. Set up primary template ({{Political party}} maybe?)
    2. Find templates that are designed to call /shortname, /color, and /abbrev pages
    3. Cvt #2.2 to use module, either by direct invocation or replacement with #2.1
  3. Research into none values - "", "N/A", "None of the above", "Other parties" and see if valid uses or should be replaced with no value or a global default value.

Discussion

Just starting this here to detail the progress of the setup and creation of this template. Steps will be expanded or struck as necessary. Primefac (talk) 15:53, 6 September 2021 (UTC)

  • Happy to start compiling a list of templates/modules and other situations where this will have to be used – for example colour templates are often used by themselves in wikitables, so we'll need to thing about how that works going forwards. Also, a query over the colour output – in many cases the # is needed (I noticed in the TfD discussion, the output was minus the hash). Cheers, Number 57 16:37, 6 September 2021 (UTC)
    I think it would be reasonable for parties that only have a colour value to simply return shortname = fullname (just on the off chance that someone calls it) so that it doesn't give an error. Primefac (talk) 17:13, 6 September 2021 (UTC)
    I've started a list of uses here. Number 57 17:54, 6 September 2021 (UTC)
  • Plus there are also some templates that currently do not use the meta templates, but would be improved by doing so – for instance, {{Infobox political party}} currently requires the colour of the party to be entered in the |colorcode parameter. It would make life easier for people if the infobox could use the colour associated with the article name by default (if it exists) and then overridden by anything added manually. Number 57 16:43, 6 September 2021 (UTC)
    Yeah, definitely a lot of room to almost re-evaluate how these meta templates are used. The # is an issue but from other instances I've seen such as Module:Sports color they just give the value without it, letting the template add in the # as necessary. Primefac (talk) 17:10, 6 September 2021 (UTC)
    I've added support for the # sign. I've used the html value so it the wiki doesn't translate # into a list. Gonnym (talk) 09:00, 7 September 2021 (UTC)
    The only issue there is for the "simple" colours listed, such as red or green. I'm sure we can figure it out, though. Primefac (talk) 10:46, 7 September 2021 (UTC)
    I guess the answer may be to replace the simple colours with their respective hex codes? Number 57 10:50, 7 September 2021 (UTC)
    I've adjusted the code. The database should now include the regular (non-html) hash sign, and the module searches for it and converts to html. That way, green or red should work. Gonnym (talk) 10:55, 7 September 2021 (UTC)
    Excellent. Figured there would be an easy fix. Primefac (talk) 10:58, 7 September 2021 (UTC)
  • Also, re 1.1, be aware that many meta templates are not categorised, so using the categories of a way of finding them is not going to give the full list. Is there a way of automatically creating a list of everything in template space ending with "/meta/color" and "/meta/shortname"? Number 57 16:45, 6 September 2021 (UTC)
    I got Martin Urbanec to run a PAWS query (thanks again!) and get all of the values for all templates ending in /meta/XYZ, so right now I'm working on getting them in a usable format. Primefac (talk) 17:10, 6 September 2021 (UTC)
  • Step #1.3 is done, everything is at this Sheet. I'm a little hesitant to just open it up to editing by anyone, so if someone wants to get edit access just ask via the usual methods. I have to run but I'll try to get everything loosely formatted for importing into the various submodules in the next day or two. Primefac (talk) 19:26, 6 September 2021 (UTC)
    Do you think it's worth having a stab about rationalising the list before transferring it into the module? There are multiple duplicates (e.g. {{Young People's Party (UK)/meta/color}} and {{Young People's Party UK/meta/color}}) and also many that aren't used (e.g. {{Zac Goldsmith Team/meta/color}}). Can a query be done to work out which ones aren't used?
    Also, what about redirects? There are quite a few as a result of parties that were renamed and the meta template moved to match the new name (e.g. {{HOMELAND (Slovakia)/meta/color}}). Cheers, Number 57 20:11, 6 September 2021 (UTC)
    The short answers are:
    • it will probably be a bit of both, in that I'll notice duplicates before copying things over, but will also likely not notice some duplicates until after they have been copied
    • I have no doubt a check of some variety (probably quarry) can be made to see if any of these templates are unused
    • Yes, redirects were not included in this list, and will likely be pulled/added after the main list is populated
    My main concern right now is getting the bulk of the lists sorted, in particular just getting everything moved over to the modules so that we can get a better idea of what we're dealing with for Stage 2. I've added in a few more points to Stage 1 on the thoughts here, though (#1.5-6). Primefac (talk) 00:31, 7 September 2021 (UTC)
Another issue I saw from the list is that not all entries start with a letter. I've added a fix to that so if the index isn't a letter, the index will be "1", and will search at "Module:Political party/1". The "1" isn't really important and can be any thing else. If those entries won't be included then those lines of code can be removed. Gonnym (talk) 11:57, 7 September 2021 (UTC)
Thanks, I kept forgetting to look into that. Primefac (talk) 12:37, 7 September 2021 (UTC)

Duplicates

finished duplicates

There are a very small number of straight-up duplicate names in the data, but also similar-named entries which would of course necessitate an alternate name entry. However, almost all of them are using different values. For example:

     ["All India Majlis-E-Ittehadul Muslimeen"] = {abbrev = "", color = "#009F3C", shortname = "AIMIM",},
     ["All India Majlis-e-Ittehadul Muslimeen"] = {abbrev = "", color = "#1A7920", shortname = "AIMIM",},
     ["Young People's Party (UK)"] = {abbrev = "", color = "#DDDDDD", shortname = "Young People's",},
     ["Young People's Party UK"] = {abbrev = "", color = "#FFF643", shortname = "Young People's",},

What's the best way to deal with this disparity? I'm half-tempted to just pick one of the values and let someone make an edit request if they're that worried about it (i.e. let the gnomes handle it). Primefac (talk) 11:37, 7 September 2021 (UTC)

Out of the 3 of here here, Number 57 has probably the best idea for this, so you could just make the list and they'll edit out the wrong options. Either that or you idea and someone eventually will request a fix. Gonnym (talk) 11:40, 7 September 2021 (UTC)
(e/c) I would check which one is used in the infobox of the party in question, or if neither (which is the case in the second), what is there or matches the logo. For Young People's Party, the correct colour seems to be yellow (or the second one listed). For the first one listed, neither seem to fit. I'd suggest #136b4b based on the background colour of their logo. If it is a short list, I'm happy to go through and pick? Cheers, Number 57 11:44, 7 September 2021 (UTC)
["Bangladesh Muslim League (BML)"] = {abbrev = "", color = "#D0F7F7", shortname = "",},
["Bangladesh Muslim League"] = {abbrev = "", color = "#7DE8E8", shortname = "BML",},

These are actually two separate parties. The Bangladesh Muslim League had a split, with one of the splinter factions called "Bangladesh Muslim League-BML" (this is a bit of an oddity in Bangladeshi politics and there are a few parties with names like this). The Bangladesh Muslim League (BML) one should be adjusted to Bangladesh Muslim League-BML, which would then be picked up by the results table in 2018 Bangladeshi general election. I've renamed the meta template and fixed its uses to match the "Bangladesh Muslim League-BML" name. Cheers, Number 57 15:29, 7 September 2021 (UTC)

Thanks. Done. Primefac (talk) 15:34, 7 September 2021 (UTC)

Last one (I think)

["Scottish People's Alliance"] = {abbrev = "", color = "#87cefa", shortname = "Scottish People's",},
["Scottish Peoples Alliance"] = {abbrev = "", color = "white", shortname = "Scottish Peoples Alliance",},

This one has disparity both with the colour and shortname. I'm inclined to go with the shorter version (since that's the point of a shortname) but I haven't dug into the colour yet. Primefac (talk) 18:00, 7 September 2021 (UTC)

I'd be tempted to go with the light blue one – that seems to be the original template. I can't find a party logo and the BBC just use dark gray for them, which I suspect is because they were a minor party. Number 57 19:56, 7 September 2021 (UTC)

Shading

Split from the main discussion

Another party/meta type exists - shading (see Template:People's Action Party/meta/shading). Not sure what it's used for but noticed these weren't in the sheet. Gonnym (talk) 11:00, 7 September 2021 (UTC)

If I had to guess, it's just another way of saying /meta/color. I'll see about getting their values and adding them to the list. Primefac (talk) 11:06, 7 September 2021 (UTC)
It's not the same as the meta colours - it's for background shading in tables – see e.g. the party columns in List of Malaysian State Assembly Representatives (1964–1969)#Perlis. I am not sure these are a good idea as some of the colour contrasts are very poor – perhaps they should be scrapped? Number 57 11:14, 7 September 2021 (UTC)
Well, I've seen /color values used in that way as well, but I don't necessarily disagree with you that it's not good practice (i.e. they should probably not be used in this manner). Primefac (talk) 11:20, 7 September 2021 (UTC)

Just to swing back to this, do we want /shading as its own field for return, or merge it in with the /color options? Primefac (talk) 12:36, 7 September 2021 (UTC)

Personally I'd be tempted to send them for deletion – if they are incorrectly used instead of meta/color, they should be replaced with the colour one, but I don't think use for colouring cells in tables is appropriate. Cheers, Number 57 14:03, 7 September 2021 (UTC)
Naive question: Are the Party shading templates also part of this consolidation? It looks like there are about 800 pages with that prefix, of which at least 60 have no transclusions. – Jonesey95 (talk) 07:05, 1 November 2021 (UTC)
Not at the moment. I didn't realise they existed when I put in the original TFD, and N57 makes a good point above that there might be some ACCESS/contrast issues, which is why I haven't pursued it further. Primefac (talk) 07:16, 1 November 2021 (UTC)
Sorry I'm a bit late, but one prominent use of the shading templates is as part of the Template:NZ parlbox, which is used to denote where particular New Zealand MPs served and when. See examples such as on Peter Dunne and Catherine Tizard. Deleting the shading templates would require the template, which is used on more than 1500 articles, to be redesigned. YttriumShrew (talk) 07:34, 17 November 2021 (UTC)

NA

Are the NA entries in Module:Political party/N needed?

Over 300 transclusions of the current templates, so I would say so. Primefac (talk) 17:26, 7 September 2021 (UTC)
Yes, it appears to be used for write-ins in American elections. See e.g. Maryland's_1st_congressional_district#2000s. Number 57 17:48, 7 September 2021 (UTC)
Those uses should probably be looked at during cleanup. The usage of "N/A" at {{Election box candidate with party link}} for example is pointless as it has "N/A" under the column of "Party" and links to N/A. The first is just incorrect. It is not "not available", it's just not relevant for that row (cast tables for example use {{CEmpty}} for an empty cell) and the link itself is pointless in this context. If a default color value is needed which isn't white (another question, why?) then the module can just handle that instead of returning an error at line 37. Gonnym (talk) 17:53, 7 September 2021 (UTC)
Perhaps an election box template should be created specifically for write-in lines in tables? Number 57 20:11, 7 September 2021 (UTC)
I actually think there are way too many duplicate templates that can easily be merged. See for example {{Election box candidate/sandbox}} (rough merge) which combines {{Election box candidate}}, {{Election box candidate minor party}}, {{Election box candidate no party link no change}}, {{Election box candidate with party link}}, and {{Election box candidate with party link no change}}. The styling between these is different but there is no apparent reason for why and no indication in the /doc as well, so it would seem to be just code that went out of sync. Then we can also add support to it for a no party value. Gonnym (talk) 20:51, 7 September 2021 (UTC)

Alternate names

I've come across a few alternate names that are in a different section of the alphabet (of course, I didn't write any of them down, and now can't find any) but they usually are due to translations of the original name. I suspect we'll find more when the redirect list is populated. I see two options for this:

  1. Add in the translated value into the letter (for example, if "ADF" was short for "Francophone Defense Agency" or something, we'd put the latter entry in the "/A" page even though it starts with F)
  2. Add in a secondary check into the main module (using the example in #1, the "alternate value" would now start with F, so we re-gather the information from the /F subtemplate instead of /A)

Primefac (talk) 18:32, 7 September 2021 (UTC)

I've made a testcase work for "A test" which is an alt for "Ba'ath Party".
  • {{Mlx|Political party|fetch|A test|color}} -> {{#invoke:Political party|fetch|A test|color}} (edit: removed test entry from list)
It works (and while getting it to work I found an actual bug which I fixed) but I don't know how much of a resource drain it is (not my specialty). Gonnym (talk) 19:18, 7 September 2021 (UTC)
@Primefac so it seems that using the require method in the list causes a loop. I've modified the code in the /sandbox to your second option and it seems to work:
{{#invoke:Political party/sandbox|fetch|Agrarian Party of Albania|color}} -> #21B330
Give it a look and let me know. Gonnym (talk) 17:14, 9 September 2021 (UTC)
Looks good. I was worried for a bit that we might end up with alternates in one letter going to alternates in another, but having just input all the alternates I don't think that's the case. Plus, I've added in an extra item to our checklist, in that we can have testcases for all of our values (which will throw errors if there are any such loops). Primefac (talk) 17:17, 9 September 2021 (UTC)

Not sure if this is the same thing as being discussed above (can't quite get my head round it), but in cases where a party has been renamed at some point, having a meta colour template redirect under their former name ensures the colour pointed to is the same as the one for the current name of the party (as the target is the meta colour template under the current name). How is this going to work in the module – will redirects be built into it, or will we manually have to ensure the different names have the same colours listed? Cheers, Number 57 08:30, 10 September 2021 (UTC)

Just so I understand the question I'll create an example so you can help me understand. Scenario: "Old party" is now called "New party". What should happen:
  1. Should the entry of "Old party" take the values of "New party"? That means /shortname (and /abbr) and /color values are the same.
  2. Should the entry of "Old party" only take some of the values of "New party"? If so, which?
    1. Should the /shortname (and /abbr) values be the same but /colors different?
    2. Should the /color values be the same but /shortname (and /abbr) values different?
  3. Should no values be the same? "Old party" does not connect to "New party" at all. Gonnym (talk) 08:39, 10 September 2021 (UTC)
Only the colours would remain unchanged – the short version of the old name would not match the short version of the new name. For example, in the current system, if the Conservative Party (UK) was renamed the Tory Party (UK) but kept the same colour branding etc, then we'd move Template:Conservative Party (UK)/meta/color to Template:Tory Party (UK)/meta/color and so have a redirect at the former, meaning anywhere either of them were used, we'd get the same colour. However, we'd keep Template:Conservative Party (UK)/meta/shortname and Template:Tory Party (UK)/meta/shortname separate as in articles where the party contested under the old name, that's what would have to be displayed. Hope that makes sense? Number 57 08:47, 10 September 2021 (UTC)
Separately, there may be cases where a party article is moved for disambiguation purposes, so a new listing in the module would be needed. How will the old listing be pointed to the new one? And also, this goes back to my question below about how to identify where calls are being made for the old name – how will we identify which articles are still using the old article name and potentially need updating? Number 57 08:52, 10 September 2021 (UTC)
Ok, so I've modified the code a bit to work with how you said it should. So now instead of an alt list being:
["A Better Britain - Unionist Party"] = "A Better Britain – Unionist Party",
It should be:
["A test"] = {main = "Business and Professional Group", abbrev = "AT", shortname = "atest"},
With main being the new party. In this current style, any values listed in the alt list will get used and anything else will be taken from the linked party from the main value.
See examples:
Gonnym (talk) 09:56, 10 September 2021 (UTC)
Pardon me for always being the odd one out, but if the name changes, we shouldn't be using the old one for the new group... right? If in 1975 the "Whig" party changes its name to the "Hairband" party, we want articles from '75 and prior to use "Whig", and everything after '75 to say "Hairband". Sure, the "Whig" links will likely be redirects following a move to "Hairband", but as stated elsewhere, we're only interested in the data. We have plenty of instances of "Party (year)" showing in the template; some of them are alternate names, but a lot of them have their own values.
As far as maintenance goes, people are more than welcome to ask for a TPER to update values if and when they change. Primefac (talk) 10:38, 10 September 2021 (UTC)

Name templates

There is another group of templates which might be related under Category:Political party name templates (Category:Mexico political party name templates, Category:Singapore political party name templates, and Category:Taiwan political party name templates). --Gonnym (talk) 22:11, 7 September 2021 (UTC)

Those look to be convenience link templates, much like the footy team templates. Primefac (talk) 22:22, 7 September 2021 (UTC)

Unused templates

It was easy enough to filter through the unused template redirects (~1200) when placing the alternate names, but having gone through a few of the As there's an issue with the fact that we're combining three templates into one, so it's going to take a lot of time to manually check the ~300 templates for those that might not be used in all three /abbrev, /shortname/, and /color categories. Honestly, it's a small enough number that I think having the excess isn't going to be a huge burden. Thoughts? Primefac (talk) 17:22, 9 September 2021 (UTC)

It might not be an issue (I don't really know), but 1200 is quite a lot. A bot can create a table with the transclusion counts for each party listed there and check all 3 meta/types which would save us the time of having to check it manually. I sadly can't help with that as I never took the time to see how to create and operate a bot, etc. We can probably get help at the bot request page. Gonnym (talk) 18:27, 9 September 2021 (UTC)
Sorry, I think you're misunderstanding. I did not include any of the unused redirects when I added in the alternate names today, so the alts are 1200 names lighter. I've actually gone through a few letters of the the non-redirects (~300) and there are ~20 that would be removed from extant full names, so I think it becomes a "loss" from a cost/benefit standpoint. Primefac (talk) 18:30, 9 September 2021 (UTC)
I'm still not entirely clear what you mean. Is it that 300 or so of the (non-redirect) meta templates are unused? Cheers, Number 57 19:28, 9 September 2021 (UTC)
I went through the unused templates database and pulled every template related to this project. Before I added the alternate names (i.e. template redirects) to the individual lists, I removed all of the unused values based on the dbase results. Of the ~1500 templates on the unused list, ~1200 of them were those redirects. The ~300 remaining are either /shortname, /abbrev, or /color templates, but not using one template doesn't necessarily mean that all three are not used; for example, {{Ahd 54/meta/shortname}} is unused, but {{Ahd 54/meta/color}} is used, meaning that our entry for "Ahd 54" should be kept. In looking at the values, I'm seeing about 90% of them are non-/color values, most of which are likely in use and thus would not need removing; tracking through to remove 30 templates seems a little unnecessary. Primefac (talk) 20:12, 9 September 2021 (UTC)

Out of interest, in future, how will we be able to see if a meta shortname/color is being called from anywhere when it all ends up being pointed to the module? Cheers, Number 57 19:28, 9 September 2021 (UTC)

That's a good question. I know that it is possible to track usages of parameters and their values. TemplateData has a monthly updated report but only shows the result for entries with less than 50 unique values (which is very unhelpful). That means that it is possible. We might be able to get a bot operator to create a monthly task that collects the data, compares it to the lists and prints to the table the entries with no usages. Gonnym (talk) 19:44, 9 September 2021 (UTC)
I'm going to ask the question mainly from a maintenance perspective, but... do we care? I would assume that any parties in-use today will likely stay in use, since the pages they're being used on are unlikely to be deleted or otherwise significantly modified. Just like with the handful of unused templates I mention above, I doubt we would have attrition anywhere near 100 names per year, which is a ballpark figure in my head for what would convince me to start trimming the templates due to lack of use. Primefac (talk) 20:12, 9 September 2021 (UTC)
I guess that since entries will from now need to be added from a page request and will need to be named correctly then we won't end really need to remove unused entries from the list. So maybe we don't need to do anything? Gonnym (talk) 20:28, 9 September 2021 (UTC)
The reason I ask is that it will allow finding of errors in party names in templates that call on colours/shortnames etc. Number 57 21:48, 9 September 2021 (UTC)
There's certainly something to be said for fixing some of the more blatant typos (for example "Cumann na nGaedhael" instead of the properly-spelled "Cumann na nGaedheal") but I don't think that's something we need to worry about in the immediate future, unless we see such uses and know to simply replace extant uses with the proper template(s) before we remove them all. Primefac (talk) 21:51, 9 September 2021 (UTC)

Module and template name

A bit jumping ahead, but if the module is used for parties (and not individuals) then perhaps a better name would be Module:Political party so that a query to the module for a color would make more sense:

Gonnym (talk) 15:06, 7 September 2021 (UTC)

When I created the module/name scheme I was thinking that would be good, but it would clash with {{Political party}}. I mean, I have no issue using that as the module name, but then we'd either need to come up with a different name for the implementation template, and/or risk the issue of folks confusing Template:Political party with Module:Political party. If neither of these are issues, though, I can see the benefit of a rename. Primefac (talk) 15:16, 7 September 2021 (UTC)
{{Political party}} has only six uses and I think could easily be replaced in those articles with a bit of coding, so could be taken over by a new tenmplate. Number 57 15:21, 7 September 2021 (UTC)
Either rename that template or replace with manual code would indeed be better. Gonnym (talk) 15:29, 7 September 2021 (UTC)
I've renamed it and fixed all the links, so it's free to be taken over. Number 57 15:56, 7 September 2021 (UTC)
Just to throw out one more idea, what about Module:Political party info? I keep momentarily thinking that it's too vague to just call it "political party". Primefac (talk) 15:58, 7 September 2021 (UTC)

There are a few (1, 2, 3) shortnames that include partial links. I believe this is so that when they are called as part of a wikilink, it will show two wikilinks instead of one (see for example Aberavon for the National Liberal and Conservative shortname). If we are intending this module to essentially work the same as the individual templates, I would think that it would be necessary to keep this feature intact. Primefac (talk) 21:48, 9 September 2021 (UTC)

A couple of them were also broken (as they didn't produce the correct links), and I've repaired them. Number 57 21:49, 9 September 2021 (UTC)
Actually that didn't work, so have self-reverted. Combining this section with the one created below by Gonnym on the same issue. Number 57 21:54, 9 September 2021 (UTC)

The entries that are written like ["Parnellite Home Rule League"] = {abbrev = "", color = "#99FF66", shortname = "Home Rule League]] [[Charles Stewart Parnell|(Parnellite)",} should not be supported as they can cause issues in places we might not even know to look. If a table like the one used in Cavan (UK Parliament constituency), which uses Template:Election box winning candidate with party link wants to use another link for an individual, that is fine, but that template should be changed and another field added to it. This module should not handle the presentation side, only the data. In this case, "Charles Stewart Parnell (Parnellite)" is not the name of the party. Gonnym (talk) 21:51, 9 September 2021 (UTC)

Good points. Consider any objections I might have had rescinded. Primefac (talk) 22:20, 9 September 2021 (UTC)

Ready to go?

I've shored up error handling, created the implementation templates, and have started checking usage in Template:Election box winning candidate with party link/sandbox to see if there are any major issues. So far I am seeing none.

Other than deciding on a final name for this module, and potentially how we want this template to be set up (I have created both {{political party}} as well as subpages such as {{political party/color}}) I think we're good to start replacing /meta/ template usage with our module call. Primefac (talk) 20:36, 24 September 2021 (UTC)

I think the name is good. Is there an idiot's guide somewhere as to how it'll work? If so, I'm happy to start testing it in a few templates' sandboxes. Cheers, Number 57 22:54, 24 September 2021 (UTC)
A few comments:
  1. The name should in my opinion be called Module:Political party to match the templates.
    1. If the name changes, the error categories at Module:Political party#L-3 should be modified as well.
  2. The template code ({{#invoke:Political party|fetch|{{{1|}}}|{{{2|}}}|error{{#if:{{{error|}}}||_NULL}}={{{error|}}}}}) doesn't need to have the parameters passed to it as you should get it from the frame.args table. The code can then just be {{#invoke:Political party|fetch}}.
  3. Module:Political party#L-61 is correct that it's empty and not nil (referring to your edit summary) as at that point you have a party but might not have a specific value. In how it's currently set up when a value does not exist we initialized it to an empty value.
  4. Looking at some of the data it would seem that there is a misuse with how the data was set up previously (before the module). See for example in Module:Political party/A how the shortname values for "Alliance for the Union of Romanians" and "Alliance for Tanzania Farmers Party" are actually abbreviations and how the shortname value for "Animals First" is the same as the actual name. Can we fix it before live without this causing issues? Gonnym (talk) 08:01, 25 September 2021 (UTC)
I've now noticed that while the error function does stop the module and returns right away, it produces Lua error in Module:Political_party at line 31: parameter 1 should be a party name. so maybe it would be better to just return an error message styled as one instead of an actual Lua error, as the line number is not really relevant here and is a lot of "noise" to non-technical people. Gonnym (talk) 11:19, 25 September 2021 (UTC)
Aaaaand....
  1. Done
  2. It does if we are going to just use frame and not frame:getParent().args. I'm not really bothered either way, but since we need the error handling to be in (as a blank |error= will still trigger the eventual args.error call) we might as well just keep it in the template.
  3. You're right, and I feel dumb for forgetting that.
  4. I think you're right in that it was the Wild West with regard to what went in which templates. It's worth further discussion so I'll split it into its own section.
If that's easy to do, go for it; typing in "error(stuff)" in the module is simple, but I do see your point about the user/editor-facing side of it. That being said, making it an actual script error means that it will flag in the category and someone will see it; for example, someone vandalises a backwater article and no one notices so an error sticks on the page for ages - this happened to me with one of my country flag templates a few years back. Primefac (talk) 11:39, 25 September 2021 (UTC)
Yeah, that's a fair point. I guess the question is if there are editors going through Category:Pages with script errors, which has a lot of irrelevant entries. BTW, regarding the blank |error=, I've only worked with Module:Arguments (require("Module:Arguments").getArgs) so I'm assuming that is why I've never ran into such a problem. Gonnym (talk) 11:45, 25 September 2021 (UTC)

Alternate names, redux

As mentioned in point 4 above, there are discrepancies with how the various values are being stored: some shortnames are really abbreviations, and some of them are actually the full name of the party. I think it would reasonable to store abbreviations as abbrev in the first case and remove "shortname-equals-party-name" values in the second case (since we would just return the full name anyway). From a "we are turning thousands of templates into one module" perspective, though, that would mean we would immediately have thousands of entries that are no longer returning the intended value when called in the article space (e.g. calling "Alliance for the Union of Romanians" would no longer return "AUR").

So, I guess the question is this - do we say "oh well" and just keep the status quo, or do we change everything as described above and then return something if it's there? To continue with the AUR example, we would change the current listing

   ["Alliance for the Union of Romanians"] = {abbrev = "", color = "#FCC224", shortname = "AUR",},

to

   ["Alliance for the Union of Romanians"] = {abbrev = "AUR", color = "#FCC224", shortname = "",},

and then return essentially an {{if empty|shortname | abbrev | party}} for future calls. Primefac (talk) 11:48, 25 September 2021 (UTC)

Template:Alliance for the Union of Romanians/meta/shortname is used three times. One use is from the |abbreviation= parameter of Template:Infobox political party, which pretty much shouts misuse (and the call itself can be baked into that infobox now). Two uses are eventually from Template:Infobox election/shortname. For that specific example, we can modify that template to do -> abbr->short->passed value. The question is, how many meta-templates like this are? But I would be in favor of fixing this issue so we can a clean version. Gonnym (talk) 11:56, 25 September 2021 (UTC)
I have gone through all of the subpages. If it looked like an abbreviation, it's now in the abbrev field. If it was a duplicate to the fullname, it's been removed. I'm sure I missed a few things and/or things will need tweaking, but I would say 99% of them have been taken care of.
Before we start (slowly) replacing extant uses in the template and article space, I just want to ask the reverse question from my initial post - is there a time when we wouldn't want to give abbrev -> shortname -> passed value, or (if no abbrev is asked for) shortname -> passed value? I cannot think of one but that's why talk pages exist (to bounce ideas). If we can't figure out a reason why we wouldn't want to do it this way, I think we can reasonably start going live. Primefac (talk) 15:39, 27 October 2021 (UTC)
I'll take a look at Module talk:Political party/uses later and see how current templates are setup with fallbacks and maybe get some insights from that. I would note though that even if we use the above suggested fallback scheme, we should still add a parameterized option to get the specific value or none. So something like |only=yes (name doesn't have to be "only") would get what was request. This might be rarely used or not at all maybe, but it seems correct to have it in there just in case (and it isn't really hard to code it). Gonnym (talk) 10:28, 28 October 2021 (UTC)
Apologies, I had a look at a couple of them, and couldn't work out how to integrate this module into it. In the meantime, I have been continuing to create meta templates to work with {{Infobox election}}, {{Infobox legislative election}} and {{Election results}}, but once these have been coded to work with this module, I will copy all the meta template data across into the module. Some other editors have been creating new meta templates too, but hopefully most can be picked up from here. Cheers, Number 57 10:35, 28 October 2021 (UTC)
Yeah, some cases might be easy, others less so. Primefac (talk) 10:37, 28 October 2021 (UTC)
(edit conflict) Just keep in mind that a lot of the extant /shortnames are really abbreviations, and in this module are now properly stored as abbrev. I think that's my main concern with template-swapping, as a "shortname request" in the current system may or may not be valid in the module if the shortname became an abbrev. Primefac (talk) 10:36, 28 October 2021 (UTC)
I don't think 'shortname' and 'abbrev' are really meaningful terms. 'shortname' templates are used to display a party's name in infoboxes and election box tables. In some cases a party's 'shortname' is an abbreviation (like 'SNP' for Scottish National Party) and in some cases it is part of the party's name (like 'Labour' for the Labour Party) – see the infobox of 2017 United Kingdom general election where the shortnames called are a mix of abbreviations and shortened names. I don't believe the 'abbrev' template was that widely used and I would suggest it would be simpler to just combine the two fields. Cheers, Number 57 10:42, 28 October 2021 (UTC)
There are admittedly a very small number of parties that have both (34 by my count). Some are probably a bit unnecessary, but others such as the Liberal Democrats go evenly between that and "LibDem". I'd be hesitant to assume that one is preferred over the other. Primefac (talk) 11:01, 28 October 2021 (UTC)
If you can give me a list, I'd be happy to go through them and suggest a single shortname/abbrev (and cop any subsequent flak). I've looked at the Liberal Democrats uses, and I don't think there would be any major problem with using "Liberal Democrats" instead. There seem to be only a tiny number of templates that use the abbrev template ({{Compact election box}} and {{Elected official with party link}} are the only two that I can see use the British parties' abbrev templates) and I'm not sure they justify having a completely different set of parameters.
Or alternatively, given the relatively small number of abbrev templates in existence, we leave them as they are for now and only use this module for shortnames, and once it's up and running, suggest converting the templates that use abbrev to use the shortnames stored in this instead (or find another way to avoid using them – for example, the Danish ones only seem to be used on one article, which seems particularly pointless). Number 57 11:29, 28 October 2021 (UTC)
See below.
Parties with abbrev and shortname
Alliance Party of Northern Ireland		#F6CB2F	APNI		Alliance
All-for-Ireland League				#66FF99	AFI		All-for-Ireland
Business and Professional Group			#3333CC	BP		Businessmen's Party
Commonwealth Labour Party			#b22222	ComLab		Commonwealth Labour
Democratic Socialist Party (Ireland)		#FF0099	DSP		Democratic Socialist
Democratic Left (Ireland)			#C700C7	DL		Democratic Left
Farmers' Party (Ireland)			#B8860B	FP		Farmers' Party
Green Party (Ireland)				#22AC6F	GP		Green
Irish Unionist Alliance				#9999FF	U		Irish Unionist
Irish Parliamentary Party			#99FF66	IPP		Irish Parliamentary
Independent politicians in Ireland		#DDDDDD	Ind		Independent
Irish Democratic Party				#23588C	IDP		Irish Democratic
Independents 4 Change				#FFC0CB	I4C		Inds. 4 Change
Liberal Unionist Party				#2061A2	LibU		Liberal Unionist
Liberal Democrats (UK)				#FAA61A	Lib Dem		Liberal Democrats
Liberal Party (UK)				#ffd700	Lib		Liberal
Labour Party (Ireland)				#CC0000	Lab		Labour
Labour Party (UK)				#E4003B	Lab		Labour
Mansfield Independent Forum			#DDDDDD	MIF		Mansfield Independent
National Labour Party (Ireland)			#FF7F50	NLP		National Labour Party
Northern Ireland Labour Party			#DC241f	NILP		NI Labour
National Democratic Party (Northern Ireland)	#DDFFDD	NDP		National Democratic
National Centre Party (Ireland)			#0000FF	NCP		National Centre Party
Nationalist Party (Northern Ireland)		#32cd32	Nat		Nationalist
Nationalist Party (Ireland)			#99FF66	IrishNat	Irish Nationalist
People Before Profit/Solidarity			#8E2420	PBP/S		PBP/Solidarity
Republican Labour Party				#85de59	RepLab		Republican Labour
Republican (Ireland, 1923)			#008800	Rep		Republican
Speaker of the House of Commons (United Kingdom)	white	Spkr	Speaker
Socialist Party (Ireland)			#FF3300	SP		Socialist Party
Socialist Labour Party (Ireland)		#AD3030	SLP		Socialist Labour
Social Democrats (Ireland)			#752F8B	SD		Social Democrats
Ulster Liberal Party				#DAA520	ULib		Ulster Liberal
United Left (Ireland)				#FF5555	UL		United Left
Workers' Party of Ireland			#930C1A	WP		Workers' Party
I think we need to do one or the other - allow both abbrev and shortname, or force a choice between them. With only ~30 (out of how many thousands...) having dual values, I think it's reasonable to have one "short" value; whether that is a true shorter name or a full-on abbreviation is up to the community, to be dealt with on a per-party basis. Primefac (talk) 11:47, 28 October 2021 (UTC)
Happy to go with the one short value (which, as you say, can be tweaked later if people aren't happy with them). I'll have a look through that list this evening and make some suggestions. Cheers, Number 57 12:21, 28 October 2021 (UTC)
I think in all cases, we should use the shortname rather than the abbrev. There are varying uses of the abbrev templates, but in several cases they could simply be replaced with text (e.g. at 1924 Northern Ireland local elections or 2019 Irish local elections where they are not used in a template, but simply to create the abbreviation in a table cell). Some abbrev templates are not even used in articles, only in {{Cathead Parliament of Northern Ireland}}, which appears in categories (and similar to the above, they are just used to write out a party's name and could be replaced with text). Cheers, Number 57 21:47, 28 October 2021 (UTC)

In that case, unless I hear otherwise from our third hand I'll re-combine the abbrev and shortnames, get rid of abbrev, and update the main module. Primefac (talk) 09:27, 29 October 2021 (UTC)

@Primefac went over most of the list and left my comments there but in short:
  • The abbr usages in the office holder family of templates seem like a "valid" use. By valid I mean that there is a deliberate distinction there. As I noted there, I'm not sure if that choice is user-friendly or even follows our MoS and policies (are the letters en.wiki made up things, or come from real-word?)
  • There are /abbr templates but also /abbrev templates. Did you pick those up as well?
  • A lot of current usages do not have a fall back so those templates should break with their current system.
  • Might be worthwhile adding always a default color (the color of the default background color of the table), using it like no color was used. The reason for this is that a lot of current code does "background-color: <color>" but then gets an empty string (or error?). This way there won't be an error. Another advantage is that is removes the need to do an "if module_call then module_call, else default" and instead do "module_call".
    • As a continuation to this - one of the templates did a "if /meta/color then /meta/color, else default", so maybe we can add another parameter of |default= which then if no color is found returns the requested default instead of the module default.
  • There are many election table templates but some of them are exact duplicates, others are extremely similar that can be merged with a parameter switch. There is no reason for coding stuff like this. When people at TfD claim "maintenance burden" this is exactly it.
  • After looking at the templates I'm confident that the new system can work and work better (as long as it doesn't run into memory issues).
Hope this was clear enough, if not ask and I'll try to explain better. Gonnym (talk) 17:36, 29 October 2021 (UTC)
All very good points, and I'll give some more detailed replies once I've got a bit more room in my brain, but the one question you've not answered is the one I was waiting on, namely "should we just combine abbrev and shortname and call it good?" Primefac (talk) 17:54, 29 October 2021 (UTC)
Regarding your question, the 3 Office Holder templates use specifically a abbr system in two columns so if we change that, that column would probably need a small redesign. In my opinion those single letter "abbreviations" are made up en.wiki ones and if that assumption is correct then a short name should replace them, even if that means making those columns wider. That's my opinion on that issue. Gonnym (talk) 20:12, 29 October 2021 (UTC)
Regarding the fourth bullet point, several templates/modules have the option of inputting a colour manually, so I guess the hierarchy needs to be manual input > meta template > default (you may already be thinking this, but just wanted to double check).
Regarding the office holder templates, it seems to be largely used for Scandinavian countries, where parties are known by one- or two-letter abbreviations (so these are not made up for Wikipedia purposes). Given the relatively low usage, perhaps the templates could be tweaked to allow hard coding for that column and then done via an AWB run? Similar tables exist for other countries where party names are piped rather than having abbrev templates created. Cheers, Number 57 22:25, 29 October 2021 (UTC)

This issue is still not resolved and a lot of what was in the shortname templates is still listed under abbrev, which will cause some issues as this is rolled out (for example, there is no shortname for the ANC, which will mess up South African election articles). Are we going to merge the two? If not (or at least not immediately), then the text that is in the abbrev field needs to be copied back across to the shortname field in cases where there is no shortname. Cheers, Number 57 12:46, 25 November 2021 (UTC)

The module returns the first value that isn't empty. If you ask for an abbrev, it looks for abbrev -> shortname -> input. If you ask for a shortname, it looks for shortname -> abbrev -> input. This means that we can keep the values separate in the module and we don't have to choose when a party has both an abbrev and shortname. Primefac (talk) 12:57, 25 November 2021 (UTC)
Thanks, that's good to know. However, I still think we should merge the two given the very low level of overlap. I'm also concerned that by separating them, it might give some editors the idea that (e.g.) 'ANC' cannot be a shortname (for infobox purposes) because it's an abbreviation. Cheers, Number 57 13:01, 25 November 2021 (UTC)