Template:Flag/doc: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
'''Template:Flag''' displays a flag icon | '''Template:Flag''' displays a flag icon. | ||
== Usage == | == Usage == | ||
<code><nowiki>{{flag|</nowiki>'''<nowiki> | <code><nowiki>{{flag|</nowiki>'''<nowiki>1</nowiki>'''<nowiki>}}</nowiki></code> | ||
=== | === 1 === | ||
This is the only parameter in the template and is used for defining which country's | This is the only parameter in the template and is used for defining which country's flag will be shown. | ||
* All valid settings for flags are listed in the tables below | |||
* | * This parameter is case-insensitive. | ||
* | |||
== Examples == | == Examples == | ||
{| class="wikitable" style="text-align: center | {| class="wikitable" style="text-align: center;" | ||
| style="background-color:white;border-top:hidden;border-left:hidden" | | |||
! | ! You type | ||
! You get | |||
|- | |||
! Full name | |||
| <code><nowiki>{{flag|United Nations}}</nowiki></code> | |||
| {{flag|United Nations}} | |||
|- | |||
! Alternate name | |||
| <code><nowiki>{{flag|world}}</nowiki></code> | |||
| {{flag|world}} | |||
|- | |- | ||
! Abbreviation | |||
| <code><nowiki>{{flag| | | <code><nowiki>{{flag|un}}</nowiki></code> | ||
| {{flag|un}} | |||
| {{flag| | |||
|- | |- | ||
! No parameter | |||
| <code><nowiki>{{flag| | | <code><nowiki>{{flag|}}</nowiki></code> | ||
| {{flag|}} | |||
| {{flag| | |||
|- | |- | ||
! Invalid parameter | |||
| <code><nowiki>{{flag|invalid}}</nowiki></code> | | <code><nowiki>{{flag|invalid}}</nowiki></code> | ||
| {{flag|invalid}} | | {{flag|invalid}} | ||
|} | |} | ||
== Valid settings == | == Valid settings == | ||
=== Note: United Kingdom flags === | |||
The individual flags of {{flag|uken}} England, {{flag|ukni}} Northern Ireland, {{flag|uksc}} Scotland, and {{flag|ukwa}} Wales should take preference in '''all possible circumstances''' over the {{flag|uk}} United Kingdom flag. | |||
=== | |||
The individual flags of | |||
{| class=wikitable style="width: 100%; text-align: center;" | {| class=wikitable style="width: 100%; text-align: center;" | ||
|[[Template:Flag#Miscellaneous | Misc]] · [[Template:Flag#A | A]] · [[Template:Flag#B | B]] · [[Template:Flag#C | C]] · [[Template:Flag#D | D]] · [[Template:Flag#E | E]] · [[Template:Flag#F | F]] · [[Template:Flag#G | G]] · [[Template:Flag#H | H]] · [[Template:Flag#I | I]] · [[Template:Flag#J | J]] · [[Template:Flag#K | K]] · [[Template:Flag#L | L]] · [[Template:Flag#M | M]] · [[Template:Flag#N | N]] · [[Template:Flag#O | O]] · [[Template:Flag#P | P]] · [[Template:Flag#Q | Q]] · [[Template:Flag#R | R]] · [[Template:Flag#S | S]] · [[Template:Flag#T | T]] · [[Template:Flag#U | U]] · [[Template:Flag#V | V]] · [[Template:Flag#W | W]] · [[Template:Flag#X | X]] · [[Template:Flag#Y | Y]] · [[Template:Flag#Z | Z]] | |[[Template:Flag#Miscellaneous | Misc]] · [[Template:Flag#A | A]] · [[Template:Flag#B | B]] · [[Template:Flag#C | C]] · [[Template:Flag#D | D]] · [[Template:Flag#E | E]] · [[Template:Flag#F | F]] · [[Template:Flag#G | G]] · [[Template:Flag#H | H]] · [[Template:Flag#I | I]] · [[Template:Flag#J | J]] · [[Template:Flag#K | K]] · [[Template:Flag#L | L]] · [[Template:Flag#M | M]] · [[Template:Flag#N | N]] · [[Template:Flag#O | O]] · [[Template:Flag#P | P]] · [[Template:Flag#Q | Q]] · [[Template:Flag#R | R]] · [[Template:Flag#S | S]] · [[Template:Flag#T | T]] · [[Template:Flag#U | U]] · [[Template:Flag#V | V]] · [[Template:Flag#W | W]] · [[Template:Flag#X | X]] · [[Template:Flag#Y | Y]] · [[Template:Flag#Z | Z]] | ||
| Line 1,059: | Line 1,055: | ||
{{Box|end}} | {{Box|end}} | ||
== | == Developer documentation == | ||
If you wish to add a flag, the following requirements must be followed | === How this template works === | ||
=== Image size === | # '''Template:Flag''' takes the input parameter and calls a sub-template at "Template:Flag/X". For example, <code><nowiki>{{flag|united nations}}</nowiki></code> will call [[Template:Flag/united nations]]. | ||
# This sub-template then in turn calls [[Template:Flag icon]], supplying it with a single parameter (<code><nowiki>{{Flag icon|X}}</nowiki></code>). For example, Template:Flag/united nations supplies Template:Flag icon with the single parameter <code>United Nations</code> | |||
# Template:Flag icon calls for a flag image at "File:Flag of X.png", and applies formatting such as sizing and a 1px border. For example, if Template:Flag icon is given the parameter <code>United Nations</code>, it will supply [[:File:Flag of United Nations.png]] ({{flag|un}}). | |||
* Many of the sub-templates (such as the abbreviations and alternate names) are simple redirects to a primary sub-template. For example, [[Template:Flag/un]], [[Template:Flag/global]], [[Template:Flag/international]] and [[Template:Flag/world]] all redirect to [[Template:Flag/united nations]]. Template:Flag/united nations is the primary sub-template which then calls Template:Flag icon. | |||
=== How to add a flag === | |||
If you wish to add a flag, the following requirements must be followed: | |||
==== Image size ==== | |||
*Width: equal or less than 23px | *Width: equal or less than 23px | ||
*Height: equal or less than 15px | *Height: equal or less than 15px | ||
*Aspect ratio: retained from source flag | *Aspect ratio: retained from source flag | ||
If your flag is a custom flag (e.g. {{flag|nam}}), we recommend a 23x15px flag which has a 2:3 ratio. | If your flag is a custom flag (e.g. {{flag|nam}}), we recommend a 23x15px flag which has a 2:3 ratio. | ||
=== Upload === | ==== Upload ==== | ||
*Your flag should be uploaded to <Code>File:Flag of < | *Your flag should be uploaded to <Code>File:Flag of '''ProperFlagName'''.png</code>, where <code>'''ProperFlagName'''</code> is the full name of your flag with correct capitalization | ||
*Make sure you add your flag to [[:Category:Flag Images]] | *Make sure you add your flag image to [[:Category:Flag Images]]. | ||
=== Update templates === | ==== Update templates ==== | ||
*[[Template:Flag/abbr | *Create a template at <code>Template:Flag/'''lowercaseflagname'''</code>, where <code>'''lowercaseflagname'''</code> is the full name of your flag in complete lowercase. This template should contain the code below: | ||
<pre><nowiki>{{Flag icon|</nowiki>'''ProperFlagName'''<nowiki>}}<noinclude>[[Category:Flag sub-templates]]</noinclude></nowiki></pre> | |||
*Create a template at <code>Template:Flag/'''abbr'''</code>, where <code>abbr</code> is the lowercase abbreviation of your flag. This template should be a simple redirect to the primary sub-template (<code>Template:Flag/'''lowercaseflagname'''</code>) | |||
<noinclude>[[Category:Flag Documentation Templates]]</noinclude> | **If your template has any alternate names or abbreviations, create them as simple redirects to the primary sub-template as well | ||
*Add your flag to the correct table in the [[Template:Flag/doc|documentation template]].<noinclude>[[Category:Flag Documentation Templates]]</noinclude> | |||
Revision as of 17:31, 11 May 2020
Template:Flag displays a flag icon.
Usage
{{flag|1}}
1
This is the only parameter in the template and is used for defining which country's flag will be shown.
- All valid settings for flags are listed in the tables below
- This parameter is case-insensitive.
Examples
| You type | You get | |
|---|---|---|
| Full name | {{flag|United Nations}}
|
|
| Alternate name | {{flag|world}}
|
|
| Abbreviation | {{flag|un}}
|
|
| No parameter | {{flag|}}
|
|
| Invalid parameter | {{flag|invalid}}
|
Template:Flag/invalid |
Valid settings
Note: United Kingdom flags
The individual flags of
England,
Northern Ireland,
Scotland, and
Wales should take preference in all possible circumstances over the
United Kingdom flag.
| Misc · A · B · C · D · E · F · G · H · I · J · K · L · M · N · O · P · Q · R · S · T · U · V · W · X · Y · Z |
Miscellaneous
A
af
|
Afghanistan | |
al
|
Albania | |
dz
|
Algeria | |
ad
|
Andorra | |
ao
|
Angola | |
ag
|
Antigua and Barbuda | |
ar
|
Argentina | |
am
|
Armenia | |
au
|
Australia | |
at
|
Austria | |
az
|
Azerbaijan |
B
C
E
tl
|
East Timor | |
| Timor-Leste | ||
ec
|
Ecuador | |
eg
|
Egypt | |
sv
|
El Salvador | |
uken
|
England | |
en
| ||
gq
|
Equatorial Guinea | |
er
|
Eritrea | |
ee
|
Estonia | |
sz
|
Eswatini | |
| Swaziland | ||
et
|
Ethiopia |
G
ga
|
Gabon | |
gm
|
The Gambia | |
| Gambia | ||
ge
|
Georgia | |
de
|
Germany | |
gh
|
Ghana | |
gr
|
Greece | |
gl
|
Greenland | |
gd
|
Grenada | |
gt
|
Guatemala | |
gn
|
Guinea | |
gw
|
Guinea-Bissau | |
gy
|
Guyana |
L
la
|
Laos | |
lv
|
Latvia | |
lb
|
Lebanon | |
ls
|
Lesotho | |
lr
|
Liberia | |
ly
|
Libya | |
li
|
Liechtenstein | |
lt
|
Lithuania | |
lu
|
Luxembourg |
M
N
na
|
Namibia | |
nr
|
Nauru | |
np
|
Nepal | |
nl
|
Netherlands | |
| Holland | ||
nz
|
New Zealand | |
ni
|
Nicaragua | |
ne
|
Niger | |
ng
|
Nigeria | |
kp
|
North Korea | |
mk
|
Macedonia | |
| North Macedonia | ||
ukni
|
Northern Ireland | |
no
|
Norway |
P
pk
|
Pakistan | |
pw
|
Palau | |
ps
|
Palestine | |
pa
|
Panama | |
pg
|
Papua New Guinea | |
py
|
Paraguay | |
pe
|
Peru | |
ph
|
Philippines | |
pl
|
Poland | |
pt
|
Portugal | |
pr
|
Puerto Rico |
S
T
tw
|
Taiwan | |
tj
|
Tajikistan | |
tz
|
Tanzania | |
th
|
Thailand | |
tg
|
Togo | |
to
|
Tonga | |
tt
|
Trinidad and Tobago | |
tn
|
Tunisia | |
tr
|
Turkey | |
tm
|
Turkmenistan | |
tv
|
Tuvalu |
U
ug
|
Uganda | |
| 1zqjex'"(){}<x>:/1zqjex;9 | ua
|
Ukraine |
ae
|
United Arab Emirates | |
uae
| ||
uk
|
United Kingdom | |
gb
|
Britain | |
| Great Britain | ||
us
|
United States | |
usa
|
United States of America | |
uy
|
Uruguay | |
uz
|
Uzbekistan |
X
Developer documentation
How this template works
- Template:Flag takes the input parameter and calls a sub-template at "Template:Flag/X". For example,
{{flag|united nations}}will call Template:Flag/united nations. - This sub-template then in turn calls Template:Flag icon, supplying it with a single parameter (
{{Flag icon|X}}). For example, Template:Flag/united nations supplies Template:Flag icon with the single parameterUnited Nations - Template:Flag icon calls for a flag image at "File:Flag of X.png", and applies formatting such as sizing and a 1px border. For example, if Template:Flag icon is given the parameter
United Nations, it will supply File:Flag of United Nations.png (
).
- Many of the sub-templates (such as the abbreviations and alternate names) are simple redirects to a primary sub-template. For example, Template:Flag/un, Template:Flag/global, Template:Flag/international and Template:Flag/world all redirect to Template:Flag/united nations. Template:Flag/united nations is the primary sub-template which then calls Template:Flag icon.
How to add a flag
If you wish to add a flag, the following requirements must be followed:
Image size
- Width: equal or less than 23px
- Height: equal or less than 15px
- Aspect ratio: retained from source flag
If your flag is a custom flag (e.g.
), we recommend a 23x15px flag which has a 2:3 ratio.
Upload
- Your flag should be uploaded to
File:Flag of ProperFlagName.png, whereProperFlagNameis the full name of your flag with correct capitalization - Make sure you add your flag image to Category:Flag Images.
Update templates
- Create a template at
Template:Flag/lowercaseflagname, wherelowercaseflagnameis the full name of your flag in complete lowercase. This template should contain the code below:
{{Flag icon|'''ProperFlagName'''}}<noinclude>[[Category:Flag sub-templates]]</noinclude>
- Create a template at
Template:Flag/abbr, whereabbris the lowercase abbreviation of your flag. This template should be a simple redirect to the primary sub-template (Template:Flag/lowercaseflagname)- If your template has any alternate names or abbreviations, create them as simple redirects to the primary sub-template as well
- Add your flag to the correct table in the documentation template.