Module talk:Country alias

This is an old revision of this page, as edited by Johnuniq (talk | contribs) at 10:25, 8 December 2016 (Data format: new section). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Latest comment: 8 years ago by Johnuniq in topic Data format

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.

There is a silly number of one-line templates that return either a country's flag or it's name when given an acronym (be it for the Olympics, the Commonwealth Games, or something mundane like FINA). Obviously they've been working fine so far (since they're still being used) but recent major changes to {{infobox country at games}} mean that a vast majority of those pages don't show the correct flag any more. Hence, this page.

This module takes the three-letter country code, the year, and the games being played and returns either the full name of the country or the flag associated with that country. The "year" and "games" are used to project the correct flag depending on the situation. Johnuniq, this is where I need a bit of help, because while I am pretty good with most programming languages, I'm still getting a handle on scribunto and I'm not quite sure how to make the above happen properly. I've tried to model it off of Module:Team appearances list but the order of the syntax is getting me twisted. I'd rather this get implemented sooner rather than later, hence the appeal for assistance. Let me know if a) you're willing to help, b) if I can answer any questions, c) what sort of whisky you drink because you've put in a ton of work on our mutual projects and deserve some ;) Primefac (talk) 03:13, 8 December 2016 (UTC)Reply

I'm happy to do whatever is wanted. I have not got my head around the situation yet, but my first observation is that it would be better to integrate the fullName and fullFlag tables into one table called countries or aliases or data or whatever. That may look ugly but it is always better to keep related information in one place, when possible. That avoids duplication and errors due to typos ("ALG" in one place and "AGL" in another). I can do mega-edits and am happy to integrate them if we agree that is desirable.
In fullFlag, I assume 3000 is a sentinel to mark the end of the list. Taking AHO as an example, if parameter year is 1982 or earlier, the flag is the first item; or if year is 1983–2010 inclusive, it is the second; otherwise, it's the third.
Looking at AUS, if parameter games is "1980 Summer Olympics", the flag is the last item and year is ignored. Otherwise, the flag is the first or second or third item, depending on whether year is <=1900 or 1901–1909 or >1909. What happens if games is "1980 Summer Olympic" (a typo with no "s")? Is that ignored, or is it an error? Having an error is probably better to force clean usage.
I do not see why games is needed. Why not simply provide year, and make it return the Olympics flag if year is 1980? For AUS, would the Olympics flag ever be wanted with a year that was not 1980? Perhaps "Flag of Australia.svg" is sometimes wanted for 1980 but "Olympic flag.svg" is wanted for 1980 in another context. To achieve that, games could be "yes" to select the Olympic flag if year is 1980.
The inputs to the module (parameters) are:
  • alias (country code; error if missing or invalid)
  • flag ('yes' returns flag name; otherwise returns country name)
  • year (used to determine which flag, possibly in conjunction with games)
  • 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? Johnuniq (talk) 04:09, 8 December 2016 (UTC)Reply

Data format

Perhaps something like the following would work, taking PUR as an example.

local countries = {
	-- Option 1.
	["PUR"] = {
		name = "Puerto Rico",
		{1951, "Puerto Rico Azul Celeste.png"},
		{1995, "Flag of Puerto Rico (1952-1995).svg"},
		{3000, "Flag of Puerto Rico.svg"},
		["1948 Summer Olympics"] = {"Puerto rico national sport flag.svg"},
		["1952 Summer Olympics"] = {"Puerto rico national sport flag.svg"},
		["1980 Summer Olympics"] = {"Olympic flag.svg"},
	},
	-- Option 2.
	["PUR"] = {
		name = "Puerto Rico",
		{1951, "Puerto Rico Azul Celeste.png"},
		{1995, "Flag of Puerto Rico (1952-1995).svg"},
		{3000, "Flag of Puerto Rico.svg"},
		["Summer Olympics"] = {
			["1948"] = {"Puerto rico national sport flag.svg"},
			["1952"] = {"Puerto rico national sport flag.svg"},
			["1980"] = {"Olympic flag.svg"},
		},
	},
}

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. Johnuniq (talk) 10:25, 8 December 2016 (UTC)Reply