Template:Flagicon/doc: Difference between revisions

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

|1stat=required
'''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.
|2=2

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

|2stat=optional
==Usage==
|name=
<code><nowiki>{{flagicon|name|variant=|size=|noredlink=}}</nowiki></code>
|desc=Access region flags. Eg <nowiki>{{Flagicon|Estonia}}</nowiki> produces {{Flagicon|Estonia}}

|namespace=all
;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.
|usergroup=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.
|placement=
;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]].
|usage-notes=

|type=
==Template data==
|example=
{{TemplateData header}}
|i18n-method=-
<templatedata>
|i18n-desc=
{
|seealso=
"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.",
|setscats=
"params": {
|lines=
"1": {
|shorthand=
"label": "Name",
|relieson=
"description": "Name of the country, region, city, etc.; full name is recommended for countries",
}}
"type": "string",
<includeonly>
"required": true
[[Category:Flag icon templates|*]]
},
</includeonly>
"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==
{| 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 05:41, 2 August 2021

__EXPECTED_UNCONNECTED_PAGE__

Access region flags. Eg {{Flagicon|Estonia}} produces Estonia

Usage

{{Flagicon/doc |1= |2= }}

Template parameters

ParameterDescriptionDefaultStatus
1The name of a region, such as a country, for which a "Flag of RegionName.svg" file exists on Commons.emptyrequired
2Text string to follow the flag icon; leave empty for none.emptyoptional

Additional information

The template is intended to be used in the following namespaces: all namespaces

The template is intended to be used by the following user groups: all users

Localization

This template is not intended to be localized.