Template:Flagicon/doc: Difference between revisions

From The FunKey Wiki
Content added Content deleted
WC>Rd232
No edit summary
 
(magic word for PAGESINCATEGORY rather than template)
Line 1: Line 1:
{{documentation subpage}}
{{TemplateBox
{{high-use|546000+}}
|1=1
<!-- Categories go at the bottom of this page and interwikis go in Wikidata. -->
|1d=The name of a region, such as a country, for which a "Flag of ''RegionName''.svg" file exists on Commons.

|1def=
'''Template:Flagicon''' displays a flag of the named parameter in "icon" size, currently 23×15 pixels maximally (defined in [[Template:Flagicon/core]]), plus a one-pixel border. The image also has a clickable link to the associated article. For an unlinked flag icon, use [[Template:Flagdeco]] instead.
|1stat=required

|2=2
Please consider the [[Wikipedia:Manual of Style (icons)#Flags|Manual of Style section on flag]]s before using this template.
|2d=Text string to follow the flag icon; leave empty for none.

|2def=
==Usage==
|2stat=optional
<code><nowiki>{{flagicon|name|variant=|size=|noredlink=}}</nowiki></code>
|name=

|desc=Access region flags. Eg <nowiki>{{Flagicon|Estonia}}</nowiki> produces {{Flagicon|Estonia}}
;name: The first parameter is mandatory, and identifies the name of the country, region, city, etc. A full list of available values can be found in [[:Category:Country data templates]]. For example, [[:Template:Country data Bulgaria]] is used when the ''name'' parameter is specified as <code>Bulgaria</code>. Many flags are also available via shortened "aliases", such as standard three-letter country codes as specified by [[ISO 3166-1 alpha-3]], [[List of IOC country codes|IOC]], or [[List of FIFA country codes|FIFA]]. The list of available "aliases" is found in [[:Category:Country data redirects]]. Many of these country codes could be considered obscure, so it is recommended to use the full country name.
|namespace=all
;variant: The second parameter is optional, and identifies a flag variant to be used instead of the standard flag. This is most often used for historical flags but can also be used to specify naval flags, sport-use flags, etc. The list of available flag variants for each country is documented on the specific page for the country data template. For example, [[Template:Country data Bulgaria]] includes a description of each of the available flag variations for Bulgaria. This parameter can be a named parameter (e.g.. "<code>variant=1815</code>"), or a positional parameter, always after the country name.
|usergroup=all
;size: This parameter is optional, and is used to specify the maximum width and/or height of the flag image. This parameter is specified using standard [[Wikipedia:Extended image syntax|image syntax]].
|placement=

|usage-notes=
==Template data==
|type=
{{TemplateData header}}
|example=
<templatedata>
|i18n-method=-
{
|i18n-desc=
"description": "This template displays a wikilinked flag of the named parameter in 'icon' size, currently 23×15 pixels (defined in Template:Flagicon/core) plus a one-pixel border.",
|seealso=
"params": {
|setscats=
"1": {
|lines=
"label": "Name",
|shorthand=
"description": "Name of the country, region, city, etc.; full name is recommended for countries",
|relieson=
"type": "string",
}}
"required": true
<includeonly>
},
[[Category:Flag icon templates|*]]
"variant": {
</includeonly>
"label": "Variant",
"description": "Identifies a flag variant to be used instead of the standard flag, e.g. 1815",
"type": "string",
"required": false,
"aliases": [
"2"
]
},
"size": {
"label": "Maximum dimension",
"description": "The maximum width or height, specified via standard 'extended image syntax' (e.g. x30px)",
"type": "string",
"required": false
},
"noredlink": {
"label": "No redlink",
"description": "If set to any value which evaluates as true (i.e. '1', 'true', 'yes', or 'y'), it displays nothing if the country data file doesn't exist. (The default is to display a redlink)",
"type": "string",
"required": false
}
}
}
</templatedata>

==Examples==
{| class="wikitable"
! Wikicode !! Results !! Notes
|-
| <code><nowiki>{{flagicon|Bulgaria}}</nowiki></code> || {{flagicon|Bulgaria}} ||
|-
| <code><nowiki>{{flagicon|BUL}}</nowiki></code> || {{flagicon|BUL}} || Uses the ISO/IOC/FIFA country code
|-
| <code><nowiki>{{flagicon|Bulgaria|1946}}</nowiki></code> || {{flagicon|Bulgaria|1946}} || rowspan="2"| Specifies a historical flag
|-
| <code><nowiki>{{flagicon|Bulgaria|variant=1946}}</nowiki></code> || {{flagicon|Bulgaria|variant=1946}}
|-
| <code><nowiki>{{flagicon|BUL|naval}}</nowiki></code> || {{flagicon|BUL|naval}} || Specifies the naval ensign
|-
| <code><nowiki>{{flagicon|BUL|air force}}</nowiki></code> || {{flagicon|BUL|air force}} || Specifies the air force flag
|-
| <code><nowiki>{{flagicon|Bulgaria|size=50px}}</nowiki></code> || {{flagicon|Bulgaria|size=50px}} || Sets width to 50 pixels
|-
| <code><nowiki>{{flagicon|Xanadu}}</nowiki></code> || {{flagicon|Xanadu}} || No flag for Xanadu, so displays redlink
|-
| <code><nowiki>{{flagicon|Xanadu|noredlink=yes}}</nowiki></code> || {{flagicon|Xanadu|noredlink=yes}} || No flag, so displays nothing
|}

==Implementation notes==
This template uses the data templates listed under [[:Category:Country data templates]], which contain the data specifying '''what''' to display and the formatter [[Template:Flagicon/core]], which contains the logic of '''how''' to display the flag.

* <code><nowiki>{{flagicon|Bulgaria}}</nowiki></code> → {{flagicon|Bulgaria}} — uses [[Template:Country data Bulgaria]]
* <code><nowiki>{{flagicon|BUL}}</nowiki></code> → {{flagicon|BUL}} — uses [[Template:Country data BUL]], which is a redirect to [[Template:Country data Bulgaria]]

Inside each country data template, this template uses the following parameters:
* <code>flag alias</code> — name of the image file to display
* <code>flag alias-xxxx</code> — name of the image file of flag variant <code>xxxx</code>
* <code>alias</code> — used to display the [[alt attribute]] of the image (defaults to "Flag of ''alias''")

== Tracking categories ==
*{{clc|Pages using flagicon template with unknown parameters}}

Where <code><nowiki>{{Flagicon|Foo}}</nowiki></code> is used, but the <code><nowiki>Template:Country data Foo</nowiki></code> does not exist, then a [[WP:Red link|redlink]] is displayed, ''unless'' the {{para|noredlink|yes}} parameter has been set.

Where the redlink is displayed, the page is addded to a tracking category:

* [[:Category:Flagicons with missing country data templates]] (population: {{PAGESINCATEGORY:Flagicons with missing country data templates}})

==Related templates==
* [[Template:Flag]] is used to display a wikilinked name next to the flag. The displayed name will be the same as the parameter used with the template, but the link target will be the main article for the country (in these examples, [[Bulgaria]]).
** <code><nowiki>{{flag|Bulgaria}}</nowiki></code> → {{flag|Bulgaria}}
** <code><nowiki>{{flag|BUL}}</nowiki></code> → {{flag|BUL}}
* [[Template:Flagcountry]] is also used to display a wikilinked name next to the flag. The displayed name will always be the same, regardless of whether or not a country code alias is used as the template parameter.
** <code><nowiki>{{flagcountry|Bulgaria}}</nowiki></code> → {{flagcountry|Bulgaria}}
** <code><nowiki>{{flagcountry|BUL}}</nowiki></code> → {{flagcountry|BUL}}
* [[Template:Flagdeco]] displays an unlinked flag icon without country name.
** <code><nowiki>{{flagdeco|Bulgaria}}</nowiki></code> → {{flagdeco|Bulgaria}}
For a full list of flag templates, see [[:Category:Flag template system]].

==Alternatives to avoid Wikipedia's [[WP:PEIS|Post-expand include size]] limit==
Pages with many flag icons may come close to or exceed Wikipedia's [[WP:PEIS|Post-expand include size]] limit. In these cases consider using modules or module-wrapper templates instead:
* {{tl|flagg}} is a simple wrapper for [[Module:Flagg]]: For basic use, <code><nowiki>{{flagicon|</nowiki>''country''<nowiki>}}</nowiki></code> can be replaced with <code><nowiki>{{flagg|cxxlo|</nowiki>''country''<nowiki>}}</nowiki></code>

==See also==
* [[Template:Flagicon image]]
* [[Template:Coat of arms]]
* [[Wikipedia:WikiProject Flag Template]]
* [[Regional indicator symbol]]

<includeonly>{{Sandbox other||
[[Category:Flag template system]]

}}</includeonly>

Revision as of 15:55, 27 June 2021

__EXPECTED_UNCONNECTED_PAGE__

Template:Flagicon displays a flag of the named parameter in "icon" size, currently 23×15 pixels maximally (defined in Template:Flagicon/core), plus a one-pixel border. The image also has a clickable link to the associated article. For an unlinked flag icon, use Template:Flagdeco instead.

Please consider the Manual of Style section on flags before using this template.

Usage

{{flagicon|name|variant=|size=|noredlink=}}

name
The first parameter is mandatory, and identifies the name of the country, region, city, etc. A full list of available values can be found in Category:Country data templates. For example, Template:Country data Bulgaria is used when the name parameter is specified as Bulgaria. Many flags are also available via shortened "aliases", such as standard three-letter country codes as specified by ISO 3166-1 alpha-3, IOC, or FIFA. The list of available "aliases" is found in Category:Country data redirects. Many of these country codes could be considered obscure, so it is recommended to use the full country name.
variant
The second parameter is optional, and identifies a flag variant to be used instead of the standard flag. This is most often used for historical flags but can also be used to specify naval flags, sport-use flags, etc. The list of available flag variants for each country is documented on the specific page for the country data template. For example, Template:Country data Bulgaria includes a description of each of the available flag variations for Bulgaria. This parameter can be a named parameter (e.g.. "variant=1815"), or a positional parameter, always after the country name.
size
This parameter is optional, and is used to specify the maximum width and/or height of the flag image. This parameter is specified using standard image syntax.

Template data

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. Click here to see a monthly parameter usage report for this template based on this TemplateData.

TemplateData for Flagicon

<templatedata> { "description": "This template displays a wikilinked flag of the named parameter in 'icon' size, currently 23×15 pixels (defined in Template:Flagicon/core) plus a one-pixel border.", "params": { "1": { "label": "Name", "description": "Name of the country, region, city, etc.; full name is recommended for countries", "type": "string", "required": true }, "variant": { "label": "Variant", "description": "Identifies a flag variant to be used instead of the standard flag, e.g. 1815", "type": "string", "required": false, "aliases": [ "2" ] }, "size": { "label": "Maximum dimension", "description": "The maximum width or height, specified via standard 'extended image syntax' (e.g. x30px)", "type": "string", "required": false }, "noredlink": { "label": "No redlink", "description": "If set to any value which evaluates as true (i.e. '1', 'true', 'yes', or 'y'), it displays nothing if the country data file doesn't exist. (The default is to display a redlink)", "type": "string", "required": false } } } </templatedata>

Examples

Wikicode Results Notes
{{flagicon|Bulgaria}} Bulgaria
{{flagicon|BUL}} BUL Uses the ISO/IOC/FIFA country code
{{flagicon|Bulgaria|1946}} 1946 1946 Specifies a historical flag
{{flagicon|Bulgaria|variant=1946}} Bulgaria
{{flagicon|BUL|naval}} naval naval Specifies the naval ensign
{{flagicon|BUL|air force}} air force air force Specifies the air force flag
{{flagicon|Bulgaria|size=50px}} Bulgaria Sets width to 50 pixels
{{flagicon|Xanadu}} Xanadu No flag for Xanadu, so displays redlink
{{flagicon|Xanadu|noredlink=yes}} Xanadu No flag, so displays nothing

Implementation notes

This template uses the data templates listed under Category:Country data templates, which contain the data specifying what to display and the formatter Template:Flagicon/core, which contains the logic of how to display the flag.

Inside each country data template, this template uses the following parameters:

  • flag alias — name of the image file to display
  • flag alias-xxxx — name of the image file of flag variant xxxx
  • alias — used to display the alt attribute of the image (defaults to "Flag of alias")

Tracking categories

Where {{Flagicon|Foo}} is used, but the Template:Country data Foo does not exist, then a redlink is displayed, unless the |noredlink=yes parameter has been set.

Where the redlink is displayed, the page is addded to a tracking category:

Related templates

  • Template:Flag is used to display a wikilinked name next to the flag. The displayed name will be the same as the parameter used with the template, but the link target will be the main article for the country (in these examples, Bulgaria).
    • {{flag|Bulgaria}} Bulgaria
    • {{flag|BUL}} BUL
  • Template:Flagcountry is also used to display a wikilinked name next to the flag. The displayed name will always be the same, regardless of whether or not a country code alias is used as the template parameter.
  • Template:Flagdeco displays an unlinked flag icon without country name.
    • {{flagdeco|Bulgaria}}

For a full list of flag templates, see Category:Flag template system.

Alternatives to avoid Wikipedia's Post-expand include size limit

Pages with many flag icons may come close to or exceed Wikipedia's Post-expand include size limit. In these cases consider using modules or module-wrapper templates instead:

  • {{flagg}} is a simple wrapper for Module:Flagg: For basic use, {{flagicon|country}} can be replaced with {{flagg|cxxlo|country}}

See also