User:The Three Headed Knight/Flag/Help implementation

From Simple English Wikipedia, the free encyclopedia

Implementation[change | change source]

Three types of templates are used by the flag template system, each with a different function:

  1. User-transcluded templates
  2. Country data templates (internal)
  3. Formatting templates (internal)

For example, {{flag}}, uses:

  1. {{Flag}}, to accept input parameters, such as the required country name and the optional flag variant, size, and wikilink display name.
  2. {{Country data Spain}}, to supply the image name and article name
  3. {{Country flag2}}, to actually render the image icon and wikilink

This system structure means that:

  • all country-specific data is stored within the country data templates. This makes the system easier to maintain.
  • the formatting wikicode is stored in a small number of templates. This makes the system consistency (flag data is displayed in the same format).

How it works[change | change source]

There are three steps when a flag template is used. In the previous example of {{flag}}, the templates expand as follows:

First, Template:Flag expands to call Template:Country data Spain, and make sure that all user-specified parameters are set. The first parameter to the country data template is actually the name of the formatting template. This is the method used so that the same country data template may be used with different formatting templates. The first step of expansion results in:

{{country data Spain | country flag2 | variant = | size = | name = Spain}}

If the variant (or second parameter), the size, and/or name parameters were entered in the template call, these would be set to the desired value. For example, {{flag}} would expand to:

{{country data Spain | country flag2 | variant = 1939 | size = | name = España}}

Next, the country data template expands to call the formatting template, with add all the country-specific parameters. Using the simpler example of {{flag}}, the second expansion results in:

{{country flag2 | alias = Spain | flag alias = Flag of Spain.svg | name = Spain}}

Lastly, the formatting template is expanded to:

<span class="flagicon">[[File:Flag of Spain.svg|22x20px|border |alt=|link=]]&nbsp;</span>[[Spain]]

Basic country data template structure[change | change source]

The structure (format) of all country data templates follows a standard pattern (format), which is expanded to include additional parameters when necessary. The empty boilerplate (format) for all country data templates is as follows:

{{ {{{1<noinclude>|country showdata</noinclude>}}}
| alias =
| flag alias =
| size = {{{size|}}}
| name = {{{name|}}}
}}

There are two essential values that must be specified:

  1. The alias value identifies the name of the main article associated with the flag.
  2. The flag alias value identifies the image name of the default flag.

The call of country showdata on the first line is used to automatically create the template documentation, as described below. The size = {{{size|}}} and name = {{{name|}}} statements make sure that any size and/or name parameter values are passed through from the outer template (flag, flagicon, etc.) to the inner formatting template. If these lines are missing from the country data template, the size and name function would be disabled.

Adding flag variants[change | change source]

Additional flag variants are entered by flag alias statements. The unique (different from all the rest) label for the variant is the suffix (last part) of the parameter name, as flag alias-label. Don't forget the hyphen! For example, {{Country data Mexico}} has several flag variants, one of which is specified by:

| flag alias-1934 = Flag of Mexico (1934-1968).png

So, when {{flag}} is transcluded (called and expanded), Image:Flag of Mexico (1934-1968).png is created for display. The selection of the flag variant is coded in the formatting templates.

Country data templates with at least one flag variant (in addition to the default) must also have the following line:

| variant = {{{variant|}}}

Similar to the size and name parameters as described above. This statement is required to pass the variant parameter value (e.g. 1934) from the outer flag template to the inner formatting template. If this line is missing from the country data template, variant function would be disabled.

Changing the wikilink display text[change | change source]

For the best result, the template name should match the article wikilink specified by the alias value. For example, {{Country data Russia}} contains alias = Russia, which results in a target wikilink to Russia.

Sometimes the main article name contains a disambiguation string (extra words to make the article name unique). For example, {{Country data Georgia}} contains alias = Georgia (country). So {{flag}} displays  Georgia. Note that the wikilink is Georgia (country), but the display string is "Georgia", as expected.

Template:SaywhatIn this case, an extra statement is needed to support {{Flagcountry}} correctly. The shortname alias parameter should be set to the desired text string, such as shortname alias = Georgia. The wikilink will be generated as [[alias|shortname alias]], or [[Georgia (country)|Georgia]] in this example.

National sport team template parameters[change | change source]

Any country data template that will be used with a national team template must include an additional "pass-through" parameter:

| altlink = {{{altlink|}}}

This parameter is used to form the suffix of the associated wikilink. For example, {{fb}} appends "national football team" to the country name (alias value), and this process is enabled by the altlink parameter.

In most cases, the flag and display name for national teams is the same as the same flag and display name normally used for the nation. But sometimes they are different. These cases can be processed by additional parameters in the country data template. The default wikilink can also be changed in cases where the common naming convention is not used.

Some examples:

In each of these examples, the parameter over-ride (name alias-football, flag alias-rugby league, or link alias-netball) is identified by a unique per-sport variable that is passed from the appropriate sport team template. For example, {{fb}} includes altvar = football. Therefore, any country data template that utilizes one or more team sport over-ride parameters must also include:

| altvar = {{{altvar|}}}

Template documentation[change | change source]

Country data templates "self-document" themselves through {{Country showdata}}. The first line of each country data template is an call to a formatting template, defaulting to country showdata if that parameter is missing:


For simple country data templates, nothing further needs to be done to document them. If any flag variants, redirect aliases, etc. are used with the template, they are documented by adding parameters specifically for use by country showdata. These extra parameters are enclosed in a <noinclude>....</noinclude> section as they should not be present for any other invocation of the country data template.

See {{Country showdata/doc}} for more information about how to document country data templates.

See also[change | change source]

  • {{flagIOC}} for a similar template used exclusively for Olympic Games related articles, and uses a different internal mechanism than for these templates.
  • {{Shipboxflag}} for display of flags in ship infoboxes