විකිපීඩියා:WikiProject Flag Template
Main templates
සංස්කරණයProduces a small image of the named flag.
Produces a small image of the named flag, plus a wikilink to the associated article.
- Example:
{{flag|United Kingdom}}
→ United Kingdom
Similar to flag
, but always uses the preferred display text for the wikilinked article, even if alias names (e.g. country codes) are used.
- Example:
{{flagcountry|USA}}
→ එක්සත් ජනපද
"Shortcut" flag templates
සංස්කරණයMany countries also have individual flag templates, named using standard three letter country codes so as to offer "shortcut" alternatives to the standard templates. This is a mixed blessing; some country codes (like "USA") are widely known and the corresponding shortcut templates (i.e. {{USA}}
) offer convenience, but some country codes are relatively obscure, so wiki markup would likely be clearer if the country names were spelled out in full. Also, the shortcut templates do not offer the ability to use historical flag variants (described below), and are therefore less flexible.
- Example:
{{AFG}}
→ ඇෆ්ගනිස්තානය (equivalent to{{flag|Afghanistan}}
See Wikipedia:Inline templates linking countries for a complete list.
Flag names
සංස්කරණයThe first (positional) parameter for these templates specifies the country (or other entity) to be used for the flag image. These actually identify additional templates that individually store information specific to that country. For example, the image name and main article name used by {{flag|Cuba}}
(to produce Cuba) is stored in Template:Country data Cuba. The complete set of these "country data" templates is found in Category:Country data templates.
Note that there are country data templates for many entities that are not considered countries, such as international organizations or sub-national entities. The use of "country" in these template names is only because the original implementation of the flag template system was built upon Template:Country A better name might have been "flag data", but it is likely too late for that change now.
Some examples of non-country flag templates are:
{{flag|United Nations}}
→ United Nations{{flag|European Union}}
→ European Union{{flag|Texas}}
→ සැකිල්ල:රටේ දත්ත Texas{{flag|Bavaria}}
→ සැකිල්ල:රටේ දත්ත Bavaria
Many country data templates also exist for historical nations, and these can be used to produce the historical flags with wikilinks to the appropriate articles. Some examples are:
{{flag|Austria-Hungary}}
→ සැකිල්ල:රටේ දත්ත Austria-Hungary{{flag|Qing Dynasty}}
→ Qing Dynasty{{ධජය|නාසි ජර්මනිය}}
→ නාසි ජර්මනිය
Alias names
සංස්කරණයFor added convenience, many flags can be identified by an alias name, typically a three-letter country code. For example, instead of {{flagicon|United States}}
, you could simply use {{flagicon|USA}}
to produce .
Alias names are available for almost every nation listed in ISO 3166-1 alpha-3, the list of IOC country codes, and the list of FIFA country codes. For example, {{flagicon|DEU}}
(ISO) and {{flagicon|GER}}
(IOC and FIFA) both produce . A small handful of other well-known abbreviations are also available (such as UK
, EU
, and USSR
).
Alias names are implemented as redirects in the template namespace. For example, Template:Country data FRA is a redirect to Template:Country data France. The complete set of these redirects is listed in Category:Country data redirects, and the available alias redirect(s) for a given country data template (if any) are also documented on that template's page.
When using country code aliases, template flag
will display this value for the wikilink's display text. For example:
Note that in each case, the target wikilink points to the correct article name (i.e. United States, United Kingdom, and People's Republic of China, respectively) but the display text matches the input parameter to template flag
. This may be the desired effect, such as in column headings of a large table, but if the full name is wanted, then use Template:Flagcountry instead:
{{flagcountry|USA}}
→ එක්සත් ජනපද{{flagcountry|UK}}
→ එක්සත් රාජධානිය{{flagcountry|CHN}}
→ චීනය
Alias names have a second purpose, which is to provide alternate display text for target wikilinks. For example, the main article linked by සැකිල්ල:රටේ දත්ත නැගෙනහිර ජර්මනිය is නැගෙනහිර ජර්මනිය, but Template:Country data German Democratic Republic is a redirect alias. Therefore, you can use {{flag|German Democratic Republic}}
for සැකිල්ල:රටේ දත්ත German Democratic Republic. Again, note that the target article name for the generated wikilink is still නැගෙනහිර ජර්මනිය.
Flag variants
සංස්කරණයMany countries have had different flag variations at various periods in their history. The flag template system can accomodate this by storing multiple flag variants inside country data templates. A specific flag variant is selected by specifying an additional parameter to any of the standard flag templates. This parameter is usually given as the second positional parameter to the template, but may also be given as the variant
named parameter.
- Examples
{{ධජය|ජර්මනිය|අධිරාජ්යය}}
→ ජර්මනිය{{ධජය|ජර්මනිය|variant=අධිරාජ්යය}}
→ ජර්මනිය{{flagcountry|CAN|1921}}
→ කැනඩාව{{flagicon|CAN|1921}}
→
The set of available flag variants (if any) for a specific country data template are documented on the country data template page itself. Each variant is identified by a short text label, such as empire
or 1921
in the examples above. Usually, the label identifies the year in which the flag was introduced, but this is not a mandatory style convention.
Other common parameters
සංස්කරණයSize
සංස්කරණයThe default size for all flag icons created by these templates is 22x20px, with a one pixel border. That is, the icon will be no more than 22 pixels wide, and no more than 20 pixels tall. Most flags have a horizontal orientation, so the 22 pixel width is usually the limiting dimension. These dimensions were carefully chosen to generate the best results when flagicons are used in a bulleted list with the default browser text size.
In certain situations, it might be desirable to use a larger (or smaller) size, and this is enabled with the size
named parameter, available with all standard templates.
- Examples
{{flagicon|Brazil|size=40px}}
→<small>{{flag|Italy|size=15px}}</small>
→ Italy
Name
සංස්කරණයThe display text of the target wikilink is usually automatically generated, but can always be over-ridden with the name
parameter.
- Examples
{{ධජය|දකුණු කොරියාව|name=Korea}}
→ Korea (this name is used in several sports){{flag|ROC|name=China}}
→ China (China from 1912 to 1949)
Other flag templates
සංස්කරණයSimilar to flagcountry
, but extends the wikilink by adding a suffix after the country name. This is useful when a series of per-country articles exist for a main topic.
- Examples
{{flaglink|Serbia|in the Eurovision Song Contest 2007}}
→ සැකිල්ල:Flaglink{{flaglink|AUS|at the 2002 Commonwealth Games}}
→ සැකිල්ල:Flaglink
Displays the naval ensign of the named country (identified as the naval
variant in the corresponding country data template) plus a wikilink to the main article for the country's navy.
- Example:
{{navy|UK}}
→ එක්සත් රාජධානිය නාවික හමුදාව
National sport team flag templates
සංස්කරණයOne of the most common instances of flag icon usage on Wikipedia is for national sport teams. Several sets of sport-specific templates have been developed to also use this flag template system:
- Template:bd for badminton
- Template:bk for basketball
- Template:cr for cricket
- Template:fb for පාපන්දු ක්රීඩාව
- Template:fh for field hockey
- Template:hb for handball
- Template:ih for ice hockey
- Template:nb for netball
- Template:rl for rugby league
- Template:ru for rugby union
- Template:ru7 for rugby sevens
- Template:vb for volleyball
- Template:davis and Template:fed for tennis (Davis Cup and Fed Cup)
- Template:bandy for bandy
- Template:korf for korfball
These templates have intentionally been given terse names because they tend to be used many, many times on individual pages for match results. They completely supersede a set of previously used national team-specific templates. For example, {{fb|ITA}}
replaced {{ITAf}}
, {{ru|NZL}}
replaced {{NZLru}}
, etc.
There are often several template variations available for a given sport:
- with a "w" suffix, links to women's national team articles instead
- with a "-rt" suffix, renders the flag icon to the right of the nation's name instead of to the left. This formatting style is often used in match results
- with a -big" suffix, renders the flag icon in larger size and the team name underneath the flag. This formatting style is often used in tables of tournament results.
For example, for football, the following templates are used:
Team | Standard | Right flag | Big flag |
---|---|---|---|
Men's national teams | Template:fb | Template:fb-rt | Template:fb-big |
Examples | Italy | සැකිල්ල:Fb-rt | සැකිල්ල:Fb-big |
Women's national teams | Template:fbw | Template:fbw-rt | Template:fbw-big |
Examples | ජර්මනිය | සැකිල්ල:Fbw-rt | සැකිල්ල:Fbw-big |
Implementation
සංස්කරණයThree types of templates are used by the flag template system, each with a different function:
- User-transcluded templates
- Country data templates (internal)
- Formatting templates (internal)
For example, {{flag|Spain}}
, uses:
- Template:Flag, to accept input parameters, such as the country name (mandatory) and the optional flag variant, size, and wikilink display name.
- Template:Country data Spain, to supply the image name and article name
- Template:Country flag2, to actually render the image icon and wikilink
This system architecture means that:
- all country-specific data is contained within individual country data templates, improving maintainability
- the formatting wikicode is centralized in a very small number of templates, ensuring consistency
How it works
සංස්කරණයThere are three steps in each flag template invocation.
In the previous example of {{flag|Spain}}
, the templates expand as follows:
First, Template:Flag
expands to invoke Template:Country data Spain
, and ensure 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 mechanism by which the same country data template can be used with multiple different formatting templates. Therefore, the first step of expansion results in:
{{country data Spain | country flag2 | variant = | size = | name = Spain}}
If the variant
(or second positional parameter), the size
, and/or name
parameters were specified in the user invocation, these would be set to the desired value. For example, {{flag|Spain|1939|name=España}}
would expand to:
{{country data Spain | country flag2 | variant = 1939 | size = | name = España}}
Next, the country data template expands to invoke the formatting template, plus add all the country-specific parameters. Going back to the simpler example of {{flag|Spain}}
, the second expansion results in:
{{country flag2 | alias = Spain | flag alias = Flag of Spain.svg | name = Spain}}
Lastly, the formatting template is expanded to produce:
[[Image:Flag of Spain.svg|22x20px|border|Flag of Spain]] [[Spain|Spain]]
Basic country data template structure
සංස්කරණයThe structure of all country data templates follows a standard pattern, which is extended to include additional parameters only when necessary. The empty boilerplate 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:
- The
alias
value identifies the name of the main article associated with the flag. - The
flag alias
value identifies the image name of the default flag.
The invocation of country showdata
on the first line is used to automatically generate the template documentation, as described below.
The size = {{{size|}}}
and name = {{{name|}}}
statements ensure that any user-specified size and/or name values are passed through from the outer template (flag
, flagicon
, etc.) to the inner formatting template. Omission of these lines from the country data template would cause the size and name functionality to be disabled.
Adding flag variants
සංස්කරණයAdditional flag variants are specified by individual flag alias
statements. The unique label for the variant is the suffix of the parameter name, as flag alias-label
(don't forget the hyphen). For example, Template:Country data Mexico has several flag variants, one of which is specified by:
| flag alias-1934 = Flag of Mexico (1934-1968).png
Therefore, when {{flag|Mexico|1934}}
is transcluded, Image:Flag of Mexico (1934-1968).png is rendered. 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 value (e.g. 1934
) from the outer flag template to the inner formatting template. Omission of this line will cause the flag variant selection to fail.
Alt attribute
සංස්කරණයBy default, the alt attribute text for each image is set to "Flag of alias
". For example, most browsers will display "Flag of Norway" when the mouse is hovered over the icon image of .
Sometimes it is desirable to override the alt attribute value, perhaps if only to correct the grammar of the phrase. For example, Template:Country data Bahamas contains alt attribute = Flag of the Bahamas
. Without this line, the alt attribute text would not include the "the".
Changing the wikilink display text
සංස්කරණයThe best results are obtained when the template name matches the article wikilink (as specified by the alias
value). For example, Template:Country data Russia contains alias = Russia
, which results in a target wikilink to රුසියාව.
However, there are instances where the main article name contains a disambiguation string. For example, Template:Country data Georgia contains alias = Georgia (country)
. Therefore, {{flag|Georgia}}
results in සැකිල්ල:රටේ දත්ත Georgia. Note that the wikilink is Georgia (country), but the display string is "Georgia", as expected.
In these instances, an additional statement is needed to support Template:Flagcountry properly. The shortname alias
parameter should be set to the desired text string, such as shortname alias = Georgia
. In effect, the resultant wikilink will be generated as [[alias|shortname alias]]
, or [[Georgia (country)|Georgia]]
in this specific example.
National sport team template parameters
සංස්කරණය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, Template:cr appends "national cricket 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 corresponds to the same flag and display name normally used for the nation. However, in some instances these can be over-ridden by additional parameters within the country data template. The default wikilink can also be changed in cases where the common naming convention is not used.
Some examples:
- දකුණු කොරියාව is referred to as "Korea Republic" by ෆිෆා (FIFA). Therefore, Template:Country data South Korea includes
name alias-football
so that{{fb|දකුණු කොරියාව}}
produces දකුණු කොරියාව - In many sports, all-Ireland teams compete with athletes from both the Republic of Ireland and Northern Ireland, and often under unique flags for each sport. Template:Country data Ireland includes unique flags for several sports teams, such as
flag alias-field hockey = Flag of Ireland hockey team.svg
, so that{{fh|Ireland}}
produces සැකිල්ල:Fh - The New Zealand netball team is described at the Silver Ferns article, so to avoid the redirect at New Zealand national netball team, Template:Country data New Zealand contains
link alias-netball = Silver Ferns
so that{{nb|New Zealand}}
produces සැකිල්ල:Nb
In each of these examples, the over-ride parameter (name alias-football
, flag alias-field hockey
, or link alias-netball
) is identified by a unique per-sport variable that is passed from the appropriate sport team template. For example, Template: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
සංස්කරණයCountry data templates "self-document" themselves through Template:Country showdata. Recall that the first line of each country data template is an invocation 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 Template:Country showdata/doc for more information about how to document country data templates.
Future work
සංස්කරණයUse ImageMap for clickable icons
සංස්කරණයOne idea that has been proposed is to use the ImageMap extension so that clicking on the flag icon will go to the article on the country instead of the image page for the flag. For example,
<imagemap> Image:Flag of Canada.svg|22px|border|Flag of Canada default [[Canada]] desc none </imagemap>
results in:
Clicking on this icon brings up the page on Canada instead of Image:Flag of Canada.svg. Unfortunately, the ImageMap syntax currently does not allow for image names, links, etc. to be parameterized, but must be hardcoded to specific values, as in the previous example. See Bugzilla:8835 for comments. Also, the imagemap does not seem to support "inline" image placement.
Add user preference to disable display of flag icons
සංස්කරණයUsers that do not like flag icons should be able to disable them with a preference setting. One idea that has been tried is using a CSS class within the internal formatting template, and change the class setting from the user's monobook.css file.
For example, the code for Template:Country flagicon2 was changed to
...<span class="flagicon">[[Image:...]]</span>...
Flag image rendering would be disabled by:
{ .flagicon display:none; }
This mechanism mostly worked, but had to be reverted because it failed if a flag template was itself used as a positional parameter for another template. Many sports templates (e.g. Template:Round8) use positional parameters instead of named parameters, and are frequently used with national teams. The underlying fault is that the =
sign is being interpreted as a template parameter instead of part of the HTML code. Bugzilla:5138 appears to relate to this behaviour.
See also
සංස්කරණය- {{flagIOC}} for a similar template used exclusively for Olympic Games related articles, and uses a different internal mechanism than for these templates.
Internal project templates
සංස්කරණය- {{WikiProject Flag Template}} – banner for talk pages of template and flag-related project pages
Archives
සංස්කරණය- /Archive1 – Archive of project when testing of flag template was completed. June 23 2005
- Revision as of 8 January 2007 – description of the previous version of the flag template system
- Revision as of 3 November 2007 – before this page was completely rewritten