Difference between revisions of "Template:Country alias"

From blackwiki
Jump to navigation Jump to search
imported>Primefac
(Undid revision 878948122 by Primefac (talk) ugh... still something wrong that I'm missing - note to test Swaziland at the Olympics)
imported>Johnuniq
 
Line 1: Line 1:
 
<includeonly>{{#invoke:Country alias|main
 
<includeonly>{{#invoke:Country alias|main
  |alias={{#switch:{{{1|{{{country}}}}}}
+
  |alias={{{1|{{{country}}}}}}
                  | ANG = {{#ifeq:{{{games|}}}|Commonwealth Games|ANG_CGF|ANG}}
 
                  | GBR = {{#switch:{{{games|}}}
 
                          |World Championships in Athletics
 
                          |European Athletics Championships=GBR_WCA
 
                          |European Championships={{#ifeq:{{{year|}}}|2018|GBR_WCA|GBR}}
 
                          |GBR}}
 
                  | HKG = {{#ifeq:{{{games|}}}|Commonwealth Games|HKG_CGF|HKG}}
 
                  | IOA = {{#ifeq:{{#if:{{{fullName|}}}|{{#invoke:String|match|{{{fullName|}}}|^%d+|ignore_errors=1|plain=0}}|{{{year|}}}}}|2000|IOA_2000|IOA}}
 
                  | SWZ = {{#ifeq:{{#if:{{{fullName|}}}|{{#invoke:String|match|{{{fullName|}}}|^%d+|ignore_errors=1|plain=0}}|{{{year|}}}}}|2018|SWZ_YO2018|SWZ}}
 
                  | #default = {{{1|{{{country}}}}}}
 
        }}
 
 
  |flag={{{flag|}}}
 
  |flag={{{flag|}}}
 +
|fullName={{{fullName|}}}
 
  |year={{#if:{{{fullName|}}}|{{#invoke:String|match|{{{fullName|}}}|^%d+|ignore_errors=1|plain=0}}|{{{year|}}}}}
 
  |year={{#if:{{{fullName|}}}|{{#invoke:String|match|{{{fullName|}}}|^%d+|ignore_errors=1|plain=0}}|{{{year|}}}}}
 
  |games={{#if:{{{fullName|}}}|{{#invoke:String|replace|{{{fullName}}}|^%d+ ?|ignore_errors=1|plain=0}}|{{{games|}}}}}
 
  |games={{#if:{{{fullName|}}}|{{#invoke:String|replace|{{{fullName}}}|^%d+ ?|ignore_errors=1|plain=0}}|{{{games|}}}}}
 
  |error{{#if:{{{error|}}}||_NULL}}={{{error|}}}
 
  |error{{#if:{{{error|}}}||_NULL}}={{{error|}}}
}}</includeonly><noinclude>{{documentation}}<!--
+
}}</includeonly><noinclude>{{documentation}}
 
+
</noinclude>
Anguilla and Angola both use ANG, but since Anguilla is only called via the Commonwealth Games it has been designated ANG_CGF in the Module (and will only be called when "Commonwealth Games" is passed to {{{games}}}).
 
 
 
Hong Kong is no longer a part of the Commonwealth, and to avoid their current flag showing on Commonwealth-related issues HKG_CGF is implemented to avoid their post-colonial flag.
 
 
 
Great Britain goes by that name at most events except the World Championships in Athletics, so GBR_WCA is implemented to link to the "proper" name.
 
 
 
The IOC code IOA was used at the 2000 Summer Olympics to denote the Individual Olympic Athletes. At the 2012 and 2016 Summer Olympics IOA used again but was changed to Independent Olympic Athletes.
 
 
 
Since these are more back-end fixes they're listed here instead of the /doc.
 
 
 
--></noinclude>
 

Latest revision as of 04:07, 31 January 2019

Template documentation[view] [edit] [history] [purge]

This template returns either a country name or the flag associated with that country, depending on the input parameters.

Template:T is primarily meant to be used for sporting competitions such as the Olympics, Commonwealth Games, Asian Games, etc.

Usage

There is one required parameter and three optional parameters.

country/1
The three-letter country code used by IOC, CGF, or FINA. This parameter can be an unnamed parameter.
flag
If set to yes, will return the flag of the country.
year
The input year will determine which flag is used. For example, any year before 1999 will give "Pre-1999 Flag of Tunisia.svg" for Tunisia (TUN), while any year after 1999 will give "Flag of Tunisia.svg".
games
This is another method of determining which flag is used. Some countries, such as Great Britain, used the Olympic flag during the 1980 Summer Olympics.

Examples

Here are some examples based on the entry for Italy (ITA)

ITA = {
	name = "Italy",
	{1946, "Flag of Italy (1861-1946).svg"},
	{2002, "Flag of Italy.svg"},
	{2006, "Flag of Italy (2003-2006).svg"},
	"Flag of Italy.svg",
	["Summer Olympics"] = {
		[1980] = "Olympic flag.svg",
	},
  • {{Country alias|ITA}} → Italy
  • {{Country alias|ITA|flag=yes}} → Flag of Italy.svg
  • {{Country alias|ITA|flag=yes|year=1946}} → Flag of Italy (1861-1946).svg
  • {{Country alias|ITA|flag=yes|year=1947}} → Flag of Italy.svg
  • {{Country alias|ITA|flag=yes|year=1980|games=Summer Olympics}} → Olympic flag.svg
  • {{Country alias|ITA|flag=yes|year=2006|games=Summer Olympics}} → Flag of Italy (2003–2006).svg

Note that in the last example games does not factor into the flag image.

Lua script error messages

If the country code is not supplied, or does not exist in the module, an error will be returned:

  • {{Country alias}}Lua error in Module:Country_alias at line 148: Invalid country alias: {{{country}}}.
  • {{Country alias|}}Lua error in Module:Country_alias at line 148: Invalid country alias: nil.
  • {{Country alias|EXZ}}Lua error in Module:Country_alias at line 148: Invalid country alias: EXZ.
  • {{Country alias|country=EXZ}}Lua error in Module:Country_alias at line 148: Invalid country alias: EXZ.

To avoid generating a script error, use |error=value.

  • {{Country alias|EXZ|error=ERROR}} → ERROR