{{Flagg}}
(flag general) is a flag template with variable output format. Using Lua instead of the standard mechanism, it allows overriding the image name and link target, and works even if a country data template for an entity does not exist (without using any expensive functions).
The template is not intended to fully supersede any specific flag templates it can simulate (see below), but can be useful for formats for which no template exists, or if its additional options are needed. It can also be used to reduce post-expand include size of pages with lots of templates.
Aliases (alternatives) for each parameter or value are given in square brackets.
The first parameter is an alphabetic code specifying the output format. The first letter concerns the image, the second the separator, and the third the country name. The parameter is fully case-insensitive.
If any position in the parameter value is missing or has a character not corresponding to an option below, the options marked as default will be used; e.g. a first parameter equal to i
, i**
or izz
will be read as isc
.
First letter: Image
Second letter: Separator
Third letter: Name
Some additional options can be enabled by appending the following letters to the three-letter code in any order:
The second parameter is the country or entity name. The template attempts to read the flag and link data from "Template:Country data country"; if that does not exist, the same parameter will be used as default country link and no automatic image will be displayed. The parameter also defines the default displayed country name, if the .mw-parser-output .monospaced{font-family:monospace,monospace}e option above is not used.
|variant=
[third unnamed parameter]{{flagg|ixx|Germany|naval}}
→ |image=
|size=
[|sz=
]|border=
|border=
can be set to "yes" ["y", "1"] to force a border when excluded by default, or "no" ["n", "0", empty string] to prevent one.|align=
[|al=
]|width=
[|w=
]|alt=
|ilink=
|noredlink=no
notext
, no text will be displayed alongside the red link. Defaults to "yes" (no red link displayed).|missingcategory=category name
|name=
|clink=
[|link=
]|pref=
, |suff=
, |plink=
|pref=
and |suff=
set the prefix and suffix to use for the prefix/suffix links (format letters f, p and b). The default, if neither is specified, is "Flag of" as prefix (cf. {{flagof}}) and no suffix. |plink=
can be used to override the combined link.|the=
{{flagg|usf|Philippines|the=1}}
→ |pthe=
if the link needs "the" but the name doesn't, and |nthe=
if the name needs it but the link doesn't.|section=
|csection=
for a section of the country article, and |psection=
for a section of the prefixed/suffixed article.|altvar=
[|avar=
], |age=
{{flagg|usp|Ireland|avar=ru}}
→ |age=
.|nalign=
[|nal=
]|preftext=
 
unless the x or n separator options are specified (in which case it will use nothing or a line break, respectively).|text=
|nodata=y
{{country data ...}}
template, which is useful when the corresponding data template doesn't exist.|pref2=
, |suff2=
, |plink2=
, |psection2=
Formats:
{{flagg|usc|Fiji}}
→ {{flagg||Fiji}}
→ {{flagg|pnbr|Fiji}}
→ Flag of Fiji <span style="display:inline-block;text-align:center;">{{flagg|ilf|Fiji|sz=xl}}</span>
→ Table format & alignment:
{{flagg|usu|Switzerland}}
→ {{flagg|usu|Switzerland|al=l}}
→ {{flagg|usu|Switzerland|al=c}}
→ {{flagg|usu|Switzerland|al=r}}
→ Standard image & name parameters:
{{flagg|isc|Myanmar}}
→ {{flagg|isc|Myanmar|border=}}
→ {{flagg|isc|Myanmar|1974}}
→ {{flagg|isc|Myanmar|variant=1974}}
→ {{flagg|isc|Myanmar|name=Burma|variant=1974}}
→ {{flagg|isc|Burma|variant=1974}}
→ {{flagg|isc|Myanmar|sz=30}}
→ {{flagg|isc|Myanmar|size=30}}
→ {{flagg|isc|Myanmar|size=30px}}
→ {{flagg|isc|Myanmar|size=30x18px}}
→ {{flagg|isc|Myanmar|size=xs}}
→ {{flagg|isc|Myanmar|size=xl}}
→ {{flagg|isc|Myanmar|width=30|size=xs}}
→ {{flagg|isc|Myanmar|image=}}
→ {{flagg|isc|Myanmar|image=Flag of None.svg}}
→ {{flagg|isc|Myanmar|image=File:Flag of None.svg}}
→ Links and altvars:
{{flagg|psp|Egypt}}
→ {{flagg|psf|Egypt}}
→ {{flagg|psb|Egypt}}
→ {{flagg|psb|Philippines|the=1}}
→ {{flagg|csc|Egypt|section=History}}
→ {{flagg|csb|Egypt|csection=History}}
→ {{flagg|psb|Egypt|psection=Kingdom of Egypt (1922–1953)|variant=1922}}
→ {{flagg|psb|Egypt|plink=List of Egyptian flags}}
→ {{flagg|psf|Egypt|pref=History of}}
→ {{flagg|psp|Egypt|suff=at the Olympics}}
→ {{flagg|psp|Egypt|avar=fb}}
→ {{flagg|psp|Egypt|avar=football}}
→ {{flagg|psp|Egypt|avar=fbu|age=20}}
→ {{flagg|psl|Egypt|avar=navy}}
→ {{flagg|unapi|EGY|preftext=Sara Ahmed}}
→ Non-existing data template:
{{flagg|isc|EUSSR|nodata=1}}
→ {{flagg|isc|EUSSR|image=EUSSR red flag.svg|size=xl|nodata=1}}
→ For example:
Once you have a table with {{flaglist}}, and/or other flag template such as {{flag}}, it is easy to convert the links to specialized links. So instead of Oklahoma you would have Incarceration in Oklahoma, or if that article does not exist, then Crime in Oklahoma.
This works with full country or US state names. Also with abbreviated (3-letter) country names, and abbreviated (2-letter) US state names.
Use a global find-and-replace as previously described, but without regular expressions. Replace:
{{flag|
{{flaglist|
with
{{flagg|us*eft|pref=Incarceration in|pref2=Crime in|
The bar after flag or flaglist is necessary to avoid problems in case you have to replace 2 flag templates.
The {{flagg}} template looks for the articles. If it finds one of the two choices it adds the link and an asterisk after the location name. If it does not find either article, it just adds the standard link.
Substitute your preferred topics in the pref= and pref2= spots.
{{flagg|us*eft|
usually left aligns the text of that column (due to the "t" at the end of the code). For some unknown reason that is not always true. In that case each cell in that column will need style=text-align:left
in it. Or use the whole column code described here: #Column alignment and here: {{Table alignment}}. See example table.
Washington, D.C. - Have to force the full name to be shown:
{{flagg|us*eft|pref=Crime in|Washington, D.C.|name=Washington, D.C.}}
This particular use of {{flagg}} parameters is expensive and can only be used on a few hundred links per article. Every time the article is saved it occurs, even for null edits. So only one big country table per article. Other country tables in the same article should use standard links.
In List of countries by incarceration rate the {{flagg}} template creates a link to Incarceration in United States. That link is a redirect to Incarceration in the United States. Add "the" as necessary to create redirect pages. Admins will delete redirects that are not linked from within Wikipedia. So if you need to create redirects be sure to use them right away in an article table. Or keep them in a sandbox that the admins can see until you use them in an article table. See examples. See list.
{{Flagg}} removes the names of the countries behind territories, subnational areas, etc.. This makes for more compact tables. Other flag templates (such as {{flaglist}}) do not do that. But that template can not create specialized country links.
See Global Search at Toolforge. Search for
"{{flagg|us*eft" - in quotes. To get transclusion count and list of articles.
The {{flagg}} template does not work if colspan is used before the country/state name. {{flag+link}} works. See: Template talk:Flagg#Does not work with colspan. See section farther down for {{flag+link}} info: #Without asterisks. Only one preference.
These "specialized" templates predate Flagg, and while most do not have options for custom links and images, they are probably faster because they only do two transclusions without invoking Lua.
The football templates are used as examples here; other sports that have separate templates work correspondingly.