Content deleted Content added
→Data format: new section |
m Replaced deprecated <source> tags with <syntaxhighlight> (via WP:JWB) |
||
(27 intermediate revisions by 5 users not shown) | |||
Line 1:
#REDIRECT [[Template talk:Country alias]]
{{Rcat shell|
{{R from remote talk page}}
}}
Putting a redirect here so that non-technical discussions about this module can take place at the template that calls it.
{{split article|from=Module talk:Country alias|to=Template talk:Country alias|date=15 January 2017|from_oldid=760120444|diff=760120590}}
==Getting this module started==
I'm going to start this discussion here rather than on any user talk pages mostly for a central discussion to take place.
Line 15 ⟶ 23:
:*games (used to determine which flag)
:Is that all correct? If so, I'll muck around with it and am likely to do something withing 24 hours. Anything else? [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 04:09, 8 December 2016 (UTC)
::To answer in order:
::Combining the two sets of data (as in the next section) is an excellent idea.
::Yes, 3000 was meant as the "upper limit" so that a simple "if less than" statement could be made.
::If the games are spelled wrong, then as you imply it would just match the year. Having the right country but the wrong flag probably isn't the end of the world (given that about 75% of them are broken at the moment anyway due to bad switches in the existing templates).
::To use the 1980 example: there were both Summer and Winter Olympics. So if {{para|games|Winter Olympics}} we wouldn't want to return "Olympic flag.svg". Additionally, in your Option 2 below, this would allow Chinese Taipei (which has six different flags depending on which Games they're playing at) to be much easier to code.
::Everything else looks correct. I'll add some more thoughts to the next section as well. [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 12:59, 8 December 2016 (UTC)
== Data format ==
Perhaps something like the following would work, taking PUR as an example.
<
local countries = {
-- Option 1.
Line 44 ⟶ 58:
},
}
</syntaxhighlight>
I need to know what inputs would cause "1948 Summer Olympics" and similar entries to be used. I don't understand what the idea is there. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 10:25, 8 December 2016 (UTC)
:Option 2 is far superior, mostly because it would mean not having to combine "year" and "games". It would also mean Chinese Taipei would be easier to code (it has a different flag depending on which games they're playing). As far as what's actually calling this module: most would be from {{t|infobox country at games}}, which requires year, games, and country code. [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 13:02, 8 December 2016 (UTC)
===Format 2===
I'm now thinking of using the following format. The following shows a simple case and a more complex example based on PUR. There is no need to use 3000 as a special code.
<syntaxhighlight lang="Lua">
local countries = {
["ADN"] = {
name = "Aden",
"Flag of the Colony of Aden.svg"
},
["EXA"] = {
name = "Example Country",
{1951, "Flag1951.svg"},
{1995, "Flag1995.svg"},
"FlagOther.svg",
["Summer Olympics"] = {
{1948, "SO1948.svg"},
{1952, "SO1952.svg"},
{1980, "SO1980.svg"},
},
},
}
</syntaxhighlight>
Here is how I think it would work.
<pre>
INPUT OUTPUT
{{#invoke:Country alias|_main}} Example Country
{{#invoke:Country alias|_main|flag=yes|year=1950}} Flag1951.svg
{{#invoke:Country alias|_main|flag=yes|year=1951}} Flag1951.svg
{{#invoke:Country alias|_main|flag=yes|year=1995}} Flag1995.svg
{{#invoke:Country alias|_main|flag=yes|year=1996}} FlagOther.svg
{{#invoke:Country alias|_main|flag=yes}} FlagOther.svg
</pre>
How does games works with this? If games does not match "Summer Olympics", use above procedure. Otherwise, use above procedure except, use the specified exception flag if the year matches one of the exceptions?
<pre>
INPUT OUTPUT
{{#invoke:Country alias|_main|flag=yes|year=...}} (as above)
{{#invoke:Country alias|_main|flag=yes|games=Winter Olympics|year=...}} (as above)
{{#invoke:Country alias|_main|flag=yes|games=Summer Olympics|year=1948}} SO1948.svg
{{#invoke:Country alias|_main|flag=yes|games=Summer Olympics|year=1952}} SO1952.svg
{{#invoke:Country alias|_main|flag=yes|games=Summer Olympics|year=1980}} SO1980.svg
{{#invoke:Country alias|_main|flag=yes|games=Summer Olympics}} FlagOther.svg
{{#invoke:Country alias|_main|flag=yes|games=Summer Olympics|year=1944}} Flag1951.svg
{{#invoke:Country alias|_main|flag=yes|games=Summer Olympics|year=1956}} Flag1995.svg
{{#invoke:Country alias|_main|flag=yes|games=Summer Olympics|year=1992}} Flag1995.svg
{{#invoke:Country alias|_main|flag=yes|games=Summer Olympics|year=1996}} FlagOther.svg
</pre>
Is that what is wanted? I cannot do anything until I understand this, and it makes sense. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 22:40, 8 December 2016 (UTC)
:That's pretty much bang on! The loss of the 3000 is nice, too. [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 22:47, 8 December 2016 (UTC)
=== Merged ===
@[[User:Primefac|Primefac]]: I wrote a script to merge the data and format it as discussed. I don't have time to do more at the moment so I have replaced the module with the new data. I'll add the code to make it work later. Please check the TODO in the comment at the top, and do any other sanity checks you can. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 05:11, 9 December 2016 (UTC)
== Country code conflict ==
Surprisingly, there's only one country code that is used for two different countries: ANG is Anguilla via the [[Template:Country flag CGF alias ANG|CGF]] and Angola for the [[Template:Country flag IOC alias ANG|IOC]]. I have absolutely no idea how we could distinguish them. [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 14:00, 8 December 2016 (UTC)
:33 pages transclude the former (CGF) and 363 transclude the latter (IOC). I don't understand the overall picture, but it might turn out that the CGF call can specify a parameter the module could use to select a different entry. Otherwise, we would have to make a fake identifier such as ANG-CGF and change the 33 pages that need it. We can think about that later. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 01:02, 9 December 2016 (UTC)
== It's alive ==
I fixed the code in the module so it should work as discussed. It's been very rushed so quiet checking and testing is needed. Meanwhile, here are some results. The errors in the first four lines are expected because EXZ is not defined and EXX is badly defined.
*<code><nowiki>{{#invoke:Country alias|main|alias=EXZ}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXZ}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXX}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXX}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXX|flag=yes|year=1960}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXX|flag=yes|year=1960}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXX|flag=yes}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXX|flag=yes}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXX|flag=yes|year=1950}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXX|flag=yes|year=1950}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|year=1950}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|year=1950}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|year=1951}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|year=1951}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|year=1952}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|year=1952}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|year=1994}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|year=1994}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|year=1995}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|year=1995}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|year=1996}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|year=1996}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|games=Paralympics}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|games=Paralympics}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|games=Paralympics|year=1952}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|games=Paralympics|year=1952}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|games=Summer Olympics|year=1948}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|games=Summer Olympics|year=1948}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|games=Summer Olympics|year=1949}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|games=Summer Olympics|year=1949}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|games=Summer Olympics|year=1952}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|games=Summer Olympics|year=1952}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|games=Summer Olympics}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|games=Summer Olympics}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|games=Winter Olympics|year=1956}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|games=Winter Olympics|year=1956}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|games=Winter Olympics}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|games=Winter Olympics}}
*<code><nowiki>{{#invoke:Country alias|main|alias=EXA|flag=yes|games=Bogus Olympics|year=1956}}</nowiki></code> → {{#invoke:Country alias|main|alias=EXA|flag=yes|games=Bogus Olympics|year=1956}}
Please check the above and run some other tests. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:49, 9 December 2016 (UTC)
:Should the module insert prefix "File:" before the flag text? [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 10:18, 9 December 2016 (UTC)
::No, it should not insert the prefix. While it would be fine in some usage (like {{t|flagIPC}}), infoboxes invoke [[Module:InfoboxImage|InfoboxImage]], which requires only the name. [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 17:50, 9 December 2016 (UTC)
== flagIOC2 ==
{{ping|Primefac}} See [https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmprop=title&cmlimit=500&cmnamespace=0&format=xml&cmtitle=Category:Pages_with_script_errors articles with script errors] for articles in [[:Category:Pages with script errors]]. I don't have time to investigate further at the moment but the problem seems to be that the original flagIOC in [[Module:Country alias]] had the following line:
<pre>
games = games and (games .. ' Olympics') or 'Olympics'
</pre>
but there is no equivalent in flagIOC2. That line sets a default of 'Olympics' if the games parameter is not set. I don't know if the articles in the error category actually should have a games parameter or whether a default should be applied in the module. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:34, 2 December 2019 (UTC)
:I've added a {{para|games|<nowiki>{{{2|{{PAGENAME}}}}}</nowiki>}} to {{t|FlagIOC2}}, much the same as it's set up in {{t|country alias}} itself, but it doesn't seem to be fixing the error. It ''should'' just take the pagename if none is given, but given the relatively small number of pages this is affecting I don't mind terribly if that default isn't possible. [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 10:56, 2 December 2019 (UTC)
::It looks like a purge was all that was needed as there are no articles in the error category now. I could move that default into the module but it's ok in the template. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 21:41, 2 December 2019 (UTC)
|