Jump to content

Template:Flaglist/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Examples: Add example
Examples: {{flaglist|Georgia (U.S. state)|name=Georgia}}
 
(20 intermediate revisions by 2 users not shown)
Line 13: Line 13:
{| border=1
{| border=1
|-
|-
|{{flaglist|Paraguay|table=yes}}
|{{flaglist|Paraguay}}
|-
|-
|
|
Line 28: Line 28:
|{{flaglist|Iran}}
|{{flaglist|Iran}}
|-
|-
|{{flaglist|Switzerland|table=yes}}
|{{flaglist|Switzerland}}
|-
|-
|{{flaglist|Qatar}}
|{{flaglist|Qatar}}
Line 35: Line 35:
|-
|-
|{{flaglist|Niger}}
|{{flaglist|Niger}}
|-
|{{flaglist|Bosnia-Herzegovina|table=yes}}
|-
|-
|
|
Line 54: Line 56:
*{{flaglist|China}}
*{{flaglist|China}}
*{{flaglist|Niger}}
*{{flaglist|Niger}}
*{{flaglist|Bosnia-Herzegovina}}
*{{flaglist|Socialist Republic of Romania|1948}}
*{{flaglist|Socialist Republic of Romania|1948}}
|
|
Line 67: Line 70:
*{{flag|China}}
*{{flag|China}}
*{{flag|Niger}}
*{{flag|Niger}}
*{{flag|Bosnia-Herzegovina}}
*{{flag|Socialist Republic of Romania|1948}}
*{{flag|Socialist Republic of Romania|1948}}
|}
|}


{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{flaglist|Georgia (U.S. state)|name=Georgia}}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{flaglist|Germany}}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{flaglist|Germany|empire}}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{flaglist|Romania}}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{flaglist|Romania|1948}}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{flaglist|Socialist Republic of Romania}}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{flaglist|Socialist Republic of Romania|short=yes}}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{flaglist|UN}}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{flaglist|World}}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{flaglist|ITA}}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{flaglist|ITA}}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{flaglist|SUI}}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{flaglist|SUI}}</nowiki>}}
Line 85: Line 98:


If a maximum width is specified (whether both width and height, e.g. <kbd>20x10px</kbd>, or width only, e.g. <kbd>20px</kbd>), either using the {{para|size}} parameter or the data template default, the box size is equal to this width plus seven pixels. If a height is specified but a width is not (<kbd>x10px</kbd>), a box width of 2.2 times the height plus seven pixels is used. In the latter case, flags with an aspect ratio greater than 2.2 (the only such current national flag being [[Flag of Qatar|that of Qatar]]) may extend beyond the invisible box and overlap the country link at certain sizes, as seen in the table below. For this reason, if an icon size different from the default is wanted, it is best to always specify both a width and a height. This also ensures that neither squarish nor long flags are rendered much bigger than other flags.
If a maximum width is specified (whether both width and height, e.g. <kbd>20x10px</kbd>, or width only, e.g. <kbd>20px</kbd>), either using the {{para|size}} parameter or the data template default, the box size is equal to this width plus seven pixels. If a height is specified but a width is not (<kbd>x10px</kbd>), a box width of 2.2 times the height plus seven pixels is used. In the latter case, flags with an aspect ratio greater than 2.2 (the only such current national flag being [[Flag of Qatar|that of Qatar]]) may extend beyond the invisible box and overlap the country link at certain sizes, as seen in the table below. For this reason, if an icon size different from the default is wanted, it is best to always specify both a width and a height. This also ensures that neither squarish nor long flags are rendered much bigger than other flags.

<templatedata>
{
"params": {
"1": {
"label": "Country",
"description": "Display the small flag icon of this country. A flag will only be displayed if the related template {{country data ⟨1⟩}} exists with the ⟨flag alias⟩ parameter (otherwise a transparent placeholder is used to preserve text alignment inside lists).",
"example": "Germany",
"type": "string",
"required": true
},
"2": {
"aliases": [
"variant"
],
"label": "Flag variant",
"description": "Name of a variant that is configured in the country data template to display a flag variation, such as a historical flag.",
"example": "empire",
"type": "string"
},
"name": {
"description": "Custom name to be displayed instead of ⟨1⟩.",
"type": "string",
"label": "Custom name"
},
"size": {
"description": "Custom size of the flag icon.",
"example": "x25px",
"type": "string",
"default": "23x15px",
"label": "Custom flag size"
},
"short": {
"label": "Short name",
"description": "Display the ⟨shortname alias⟩ that is configured in the country data template, instead of the name given with ⟨1⟩ or ⟨name⟩. If there is no shortname alias, then ⟨alias⟩ from the country data template is used.",
"example": "yes",
"type": "boolean",
"default": "no",
"suggested": true
},
"table": {
"label": "Table alignment",
"description": "Align country names that wrap across multiple lines next to the flag icon (by creating a table). Currently only for use within tables.",
"example": "yes",
"type": "boolean",
"default": "no",
"suggested": false
}
},
"paramOrder": [
"1",
"name",
"short",
"2",
"size",
"table"
],
"description": " "
}
</templatedata>


== Usage with custom size ==
== Usage with custom size ==
Line 92: Line 165:
! width="20%" | {{tl|flag}} output
! width="20%" | {{tl|flag}} output
! width="20%" | {{tl|flaglist}} output
! width="20%" | {{tl|flaglist}} output
! width="20%" | {{tl|flaglist}} with table=yes output
|-
|-
! 10px
! 10px
Line 98: Line 172:
*{{flag|Palau|size=10px}}
*{{flag|Palau|size=10px}}
*{{flag|Switzerland|size=10px}}
*{{flag|Switzerland|size=10px}}
*{{flag|Union of Soviet Socialist Republics|size=10px}}
|
|
*{{flaglist|Qatar|size=10px}}
*{{flaglist|Qatar|size=10px}}
*{{flaglist|Palau|size=10px}}
*{{flaglist|Palau|size=10px}}
*{{flaglist|Switzerland|size=10px}}
*{{flaglist|Switzerland|size=10px}}
*{{flaglist|Union of Soviet Socialist Republics|size=10px}}
|
{|
|-
|{{flaglist|Qatar|size=10px}}
|-
|{{flaglist|Palau|size=10px}}
|-
|{{flaglist|Switzerland|size=10px|table=yes}}
|-
|{{flaglist|Union of Soviet Socialist Republics|size=10px|table=yes}}
|}
|-
|-
! x8px
! x8px
Line 108: Line 195:
*{{flag|Palau|size=x8px}}
*{{flag|Palau|size=x8px}}
*{{flag|Switzerland|size=x8px}}
*{{flag|Switzerland|size=x8px}}
*{{flag|Union of Soviet Socialist Republics|size=x8px}}
|
|
*{{flaglist|Qatar|size=x8px}}
*{{flaglist|Qatar|size=x8px}}
*{{flaglist|Palau|size=x8px}}
*{{flaglist|Palau|size=x8px}}
*{{flaglist|Switzerland|size=x8px}}
*{{flaglist|Switzerland|size=x8px}}
*{{flaglist|Union of Soviet Socialist Republics|size=x8px}}
|
{|
|-
|{{flaglist|Qatar|size=x8px}}
|-
|{{flaglist|Palau|size=x8px}}
|-
|{{flaglist|Switzerland|size=x8px|table=yes}}
|-
|{{flaglist|Union of Soviet Socialist Republics|size=x8px|table=yes}}
|}
|-
|-
! 10x8px
! 10x8px
Line 118: Line 218:
*{{flag|Palau|size=10x8px}}
*{{flag|Palau|size=10x8px}}
*{{flag|Switzerland|size=10x8px}}
*{{flag|Switzerland|size=10x8px}}
*{{flag|Union of Soviet Socialist Republics|size=10x8px}}
|
|
*{{flaglist|Qatar|size=10x8px}}
*{{flaglist|Qatar|size=10x8px}}
*{{flaglist|Palau|size=10x8px}}
*{{flaglist|Palau|size=10x8px}}
*{{flaglist|Switzerland|size=10x8px}}
*{{flaglist|Switzerland|size=10x8px}}
*{{flaglist|Union of Soviet Socialist Republics|size=10x8px}}
|
{|
|-
|{{flaglist|Qatar|size=10x8px}}
|-
|{{flaglist|Palau|size=10x8px}}
|-
|{{flaglist|Switzerland|size=10x8px|table=yes}}
|-
|{{flaglist|Union of Soviet Socialist Republics|size=10x8px|table=yes}}
|}
|-
|-
! 35px
! 35px
Line 128: Line 241:
*{{flag|Palau|size=35px}}
*{{flag|Palau|size=35px}}
*{{flag|Switzerland|size=35px}}
*{{flag|Switzerland|size=35px}}
*{{flag|Union of Soviet Socialist Republics|size=35px}}
|
|
*{{flaglist|Qatar|size=35px}}
*{{flaglist|Qatar|size=35px}}
*{{flaglist|Palau|size=35px}}
*{{flaglist|Palau|size=35px}}
*{{flaglist|Switzerland|size=35px}}
*{{flaglist|Switzerland|size=35px}}
*{{flaglist|Union of Soviet Socialist Republics|size=35px}}
|
{|
|-
|{{flaglist|Qatar|size=35px}}
|-
|{{flaglist|Palau|size=35px}}
|-
|{{flaglist|Switzerland|size=35px|table=yes}}
|-
|{{flaglist|Union of Soviet Socialist Republics|size=35px|table=yes}}
|}
|-
|-
! x25px
! x25px
Line 138: Line 264:
*{{flag|Palau|size=x25px}}
*{{flag|Palau|size=x25px}}
*{{flag|Switzerland|size=x25px}}
*{{flag|Switzerland|size=x25px}}
*{{flag|Union of Soviet Socialist Republics|size=x25px}}
|
|
*{{flaglist|Qatar|size=x25px}}
*{{flaglist|Qatar|size=x25px}}
*{{flaglist|Palau|size=x25px}}
*{{flaglist|Palau|size=x25px}}
*{{flaglist|Switzerland|size=x25px}}
*{{flaglist|Switzerland|size=x25px}}
*{{flaglist|Union of Soviet Socialist Republics|size=x25px}}
|
{|
|-
|{{flaglist|Qatar|size=x25px}}
|-
|{{flaglist|Palau|size=x25px}}
|-
|{{flaglist|Switzerland|size=x25px|table=yes}}
|-
|{{flaglist|Union of Soviet Socialist Republics|size=x25px|table=yes}}
|}
|-
|-
! 35x25px
! 35x25px
Line 148: Line 287:
*{{flag|Palau|size=35x25px}}
*{{flag|Palau|size=35x25px}}
*{{flag|Switzerland|size=35x25px}}
*{{flag|Switzerland|size=35x25px}}
*{{flag|Union of Soviet Socialist Republics|size=35x24px}}
|
|
*{{flaglist|Qatar|size=35x24px}}
*{{flaglist|Qatar|size=35x24px}}
*{{flaglist|Palau|size=35x24px}}
*{{flaglist|Palau|size=35x24px}}
*{{flaglist|Switzerland|size=35x24px}}
*{{flaglist|Switzerland|size=35x24px}}
*{{flaglist|Union of Soviet Socialist Republics|size=35x24px}}
|
{|
|-
|{{flaglist|Qatar|size=35x24px}}
|-
|{{flaglist|Palau|size=35x24px}}
|-
|{{flaglist|Switzerland|size=35x24px|table=yes}}
|-
|{{flaglist|Union of Soviet Socialist Republics|size=35x24px|table=yes}}
|}
|}
|}



Latest revision as of 15:11, 3 July 2023

This template is identical to Template:Flag except that the names are aligned correctly with flag icons of different widths. It is for use in lists of countries, states, provinces, etc.. See the documentation of Template:Flag for general documentation and available parameters.

Examples

[edit]
Example country table using {{flaglist}} and table=yes parameter Example country list using {{flaglist}} Example country list using {{flag}}
 Paraguay
San Marino
 Palau
 Australia
 Nepal
 Brazil
 Iran
 Switzerland
 Qatar
 China
 Niger
Bosnia-Herzegovina
Socialist Republic of Romania
Soviet Union
Hungarian People's Republic
 Ukraine


  • {{flaglist|Georgia (U.S. state)|name=Georgia}} Georgia
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Georgia (U.S. state).svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Georgia (U.S. state)|Georgia]]
  • {{flaglist|Germany}} Germany
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Germany.svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Germany|Germany]]
  • {{flaglist|Germany|empire}} Germany
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of the German Empire.svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Germany|Germany]]
  • {{flaglist|Romania}} Romania
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Romania.svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Romania|Romania]]
  • {{flaglist|Romania|1948}} Romania
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Romania (1948-1952).svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Romania|Romania]]
  • {{flaglist|Socialist Republic of Romania}} Socialist Republic of Romania
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Romania (1965–1989).svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Socialist Republic of Romania|Socialist Republic of Romania]]
  • {{flaglist|Socialist Republic of Romania|short=yes}} Romania
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Romania (1965–1989).svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Socialist Republic of Romania|Romania]]
  • {{flaglist|UN}} UN
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of the United Nations.svg|23x15px|border |alt=|link=]]</span>&nbsp;[[United Nations|UN]]
  • {{flaglist|World}} World
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag placeholder.svg|23x15px| |alt=|link=]]</span>&nbsp;[[World|World]]
  • {{flaglist|ITA}} ITA
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Italy.svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Italy|ITA]]
  • {{flaglist|SUI}} SUI
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Switzerland (Pantone).svg|23x16px|border |alt=|link=]]</span>&nbsp;[[Switzerland|SUI]]
  • {{flaglist|Switzerland}} Switzerland
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Switzerland (Pantone).svg|23x16px|border |alt=|link=]]</span>&nbsp;[[Switzerland|Switzerland]]
  • {{flaglist|Union of Soviet Socialist Republics|table=yes}}
Union of Soviet Socialist Republics
{| style="margin-left:-3px"
|-
| <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of the Soviet Union.svg|23x15px|border |alt=|link=]]</span> 
| style="padding-left:2px;" | [[Soviet Union|Union of Soviet Socialist Republics]]

|}
  • {{flaglist|ITA|size=46x30px}} ITA
    <span class="flagicon" style="display:inline-block;width:48px;">[[File:Flag of Italy.svg|46x30px|border |alt=|link=]]</span>&nbsp;[[Italy|ITA]]
  • {{flaglist|SUI|size=46x30px}} SUI
    <span class="flagicon" style="display:inline-block;width:48px;">[[File:Flag of Switzerland (Pantone).svg|46x30px|border |alt=|link=]]</span>&nbsp;[[Switzerland|SUI]]

How it works

[edit]

{{Flag}} generates a flag icon, a non-breaking space and the country link, which means the alignment of the link depends on the width of the flag image. The default size for flag icons is 23x15px, so the icon width is 23px for long flags but smaller for more squarish flags such as those of San Marino and Niger (any flag with an aspect ratio less than 23/15 ≈ 1.53), misaligning the country links next to them. The {{Flag/core}} template, used internally by {{flag}}, compensates for this for Nepal, Vatican City and Switzerland by inserting some extra spaces, though for several other countries the link is still shifted too far to the left, as seen above.

{{Flaglist}} puts a flag icon inside an invisible <span> box with a fixed width calculated by Module:Flaglist. The width does not depend on the exact dimensions of the image, but does vary with the maximum width and height specified using extended image syntax. The default size for most countries' flags is 23x15px; the |size= parameter can be used if a different size is wanted. Some entities have different defaults specified within their data templates and may output misaligned links even if |size= is not used.

If a maximum width is specified (whether both width and height, e.g. 20x10px, or width only, e.g. 20px), either using the |size= parameter or the data template default, the box size is equal to this width plus seven pixels. If a height is specified but a width is not (x10px), a box width of 2.2 times the height plus seven pixels is used. In the latter case, flags with an aspect ratio greater than 2.2 (the only such current national flag being that of Qatar) may extend beyond the invisible box and overlap the country link at certain sizes, as seen in the table below. For this reason, if an icon size different from the default is wanted, it is best to always specify both a width and a height. This also ensures that neither squarish nor long flags are rendered much bigger than other flags.

Template parameters

ParameterDescriptionTypeStatus
Country1

Display the small flag icon of this country. A flag will only be displayed if the related template {{country data ⟨1⟩}} exists with the ⟨flag alias⟩ parameter (otherwise a transparent placeholder is used to preserve text alignment inside lists).

Example
Germany
Stringrequired
Custom namename

Custom name to be displayed instead of ⟨1⟩.

Stringoptional
Short nameshort

Display the ⟨shortname alias⟩ that is configured in the country data template, instead of the name given with ⟨1⟩ or ⟨name⟩. If there is no shortname alias, then ⟨alias⟩ from the country data template is used.

Default
no
Example
yes
Booleansuggested
Flag variant2 variant

Name of a variant that is configured in the country data template to display a flag variation, such as a historical flag.

Example
empire
Stringoptional
Custom flag sizesize

Custom size of the flag icon.

Default
23x15px
Example
x25px
Stringoptional
Table alignmenttable

Align country names that wrap across multiple lines next to the flag icon (by creating a table). Currently only for use within tables.

Default
no
Example
yes
Booleanoptional

Usage with custom size

[edit]
|size= value {{flag}} output {{flaglist}} output {{flaglist}} with table=yes output
10px
 Qatar
 Palau
Switzerland
Union of Soviet Socialist Republics
x8px
 Qatar
 Palau
Switzerland
Union of Soviet Socialist Republics
10x8px
 Qatar
 Palau
Switzerland
Union of Soviet Socialist Republics
35px
 Qatar
 Palau
Switzerland
Union of Soviet Socialist Republics
x25px
 Qatar
 Palau
Switzerland
Union of Soviet Socialist Republics
35x25px
 Qatar
 Palau
Switzerland
Union of Soviet Socialist Republics