{{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.
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
Letter | Meaning | Description | Example |
---|---|---|---|
u | unlinked | Image is not linked (default). | {{flagg|uxx|France}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheA' not found. |
c | country | Image links to country/entity page. | {{flagg|cxx|France}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheA' not found. |
p [f ] | prefix/suffix | Image links to country name with prefixed and/or suffixed text (default "Flag of ..."), set using |pref= and |suff= (see below). | {{flagg|pxx|France}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheA' not found. |
i | image page | Image links to file description page; use this for non-public-domain images, for which attribution is required. | {{flagg|ixx|France}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheA' not found. |
d | data template | Image links to the used country data template, for use in discussion/documentation. Automatically adds redirect=no if link is a redirect. | {{flagg|dxx|France}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheA' not found. |
x | X mark | No image is displayed. If the second letter is anything other than x , and o is not set, an unlinked transparent image is actually used to preserve the spacing. | {{flagg|xnx|France}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheA' not found. |
Second letter: Separator
Letter | Meaning | Description | Example | |
---|---|---|---|---|
s | span box | The flag image is put in a fixed-width <span> tag, meaning the country names are aligned in vertical lists; see documentation of {{Flaglist}} (default). | {{flagg|usu|Niger}} → Niger | |
n | non-breaking space | A non-breaking space ( ) is used, like in most flag templates, including {{flag}}. Note that does not actually prevent wrapping between image and text in all browsers; use w as described below if needed. | {{flagg|unu|Niger}} → Niger | |
l | line break | A line break (<br/> ) is used as separator. | {{flagg|ulu|Niger}} → Niger | |
t | table cell | A table cell separator (two pipes) is used. | Niger | |
x | X mark | No separator is used. | {{flagg|uxu|Niger}} → Niger |
Third letter: Name
Letter | Meaning | Description | Example |
---|---|---|---|
c | country | The country name links to the main country/entity page (default). | {{flagg|xxc|Chile}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheD' not found. |
p | prefix/suffix | The country name links to the country page with prefixed or suffixed text (default "Flag of ..."), set using |pref= and |suff= (see below). | {{flagg|xxp|Chile}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheD' not found. |
f | full prefix/suffix | Same as p , except that the prefix and/or suffix is/are displayed. | {{flagg|xxf|Chile}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheD' not found. |
b | both country and prefix/suffix | Combined country link and prefix/suffix link: country name links to country page, while prefix and/or suffix link(s) to prefixed/suffixed title. | {{flagg|xxb|Chile}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheD' not found. |
u | unlinked (cf. {{flagu}}) | The country name is displayed as plain text, without link. | {{flagg|xxu|Chile}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheD' not found. |
d | data template | Country name is linked to the used country data template, for use in discussion/documentation. Automatically adds redirect=no if a redirect is used. | {{flagg|xxd|Chile}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheD' not found. |
x | X mark | No text is displayed. | {{flagg|xxx|Chile}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheD' not found. |
* | Add * | Similar to "p", except that an asterisk (*) is added to the text of the link if it goes to a more specific article. | {{flagg|xx*|Chile}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheD' not found. |
Some additional options can be enabled by appending the following letters to the three-letter code in any order:
Letter | Description | Example |
---|---|---|
a | Adds the country name (the "name" parameter, or if unset the second unnamed parameter) as alt text and mouseover for the image. If |alt= is used for a custom alt/mouseover text, this does not need to be separately set. | {{flagg|uxxa|Pakistan}} → |
b | Blanks the text portion if a flag is not found. | {{flagg|uncb|Xanadu}} → Compare with: {{flagg|unc|Xanadu}} → Xanadu |
e | Uses the name set in the country data template (rather than the first parameter) as display name, like in {{flagcountry}} (i.e. expands abbreviated forms). | {{flagg|unue|PAK}} → Pokiston |
f | If the prefixed/suffixed article name doesn't exist, fallback to linking to the non-prefixed/suffixed page. This may be expensive, and the number of time it can be used on single page is limited. | {{flagg|psff|Egypt|pref=Flag templates in}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheE' not found.Compare with: {{flagg|psf|Egypt|pref=Flag templates in}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheE' not found. |
l | Adds the link name (as defined by the "image" parameter) as alt text and mouseover for the image. If |alt= is used for a custom alt/mouseover text, this does not need to be separately set. | {{flagg|cxxl|PAK}} → Compare with: {{flagg|cxxa|PAK}} → |
o | Omits the image and spacing in case the image is an invisible placeholder, i.e., only include the spacing if a flag is displayed. Useful for inline/standalone usages or horizontal lists, where name alignment is not needed. | {{flagg|unuo|Pakistan|image=}} → PakistanCompare with: {{flagg|unu|Pakistan|image=}} → Pakistan |
r | Reverses the order of the elements, putting the image to the right of the name; cf. {{flagright}}. Doesn't affect the order of letters in the format code. | {{flagg|uncr|Pakistan}} → Pakistan |
w | Avoids wrapping by adding <span class="nowrap">...</span> around the output. | {{flagg|unuw|Pakistan}} → Pakistan |
t | Aligns to the left in a table. |
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 e option above is not used.
|variant=
[third unnamed parameter]{{flagg|ixx|Germany|naval}}
→ uses the "naval" variant of Template:Country data Germany.|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
|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}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheE' not found.. Use |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}}
→ Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found. uses the IRFU flag to represent the Irish rugby union team. For youth teams in some sports (see the data page), the age limit must be additionally set using |age=
.|nalign=
[|nal=
]|align=
.|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}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheK' not found. (default format){{flagg||Fiji}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheK' not found. (default format){{flagg|pnbr|Fiji}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheK' not found.<span style="display:inline-block;text-align:center;">{{flagg|ilf|Fiji|sz=xl}}</span>
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheK' not found.Table format & alignment:
{{flagg|utu|Jamaica}} | Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheG' not found. |
{{flagg|utur|Jamaica}} | Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheG' not found. |
{{flagg|utu|Jamaica|al=l|nal=l}} | Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheG' not found. |
{{flagg|utu|Jamaica|al=c|nal=c}} | Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheG' not found. |
{{flagg|utu|Jamaica|al=r|nal=r}} | Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheG' not found. |
{{flagg|usu|Switzerland}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found.{{flagg|usu|Switzerland|al=l}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found.{{flagg|usu|Switzerland|al=c}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found.{{flagg|usu|Switzerland|al=r}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found.Standard image & name parameters:
{{flagg|isc|Myanmar}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheJ' not found.{{flagg|isc|Myanmar|border=}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheJ' not found.{{flagg|isc|Myanmar|1974}}
→ Myanmar{{flagg|isc|Myanmar|variant=1974}}
→ Myanmar{{flagg|isc|Myanmar|name=Burma|variant=1974}}
→ Burma{{flagg|isc|Burma|variant=1974}}
→ Burma{{flagg|isc|Myanmar|sz=30}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheJ' not found.{{flagg|isc|Myanmar|size=30}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheJ' not found.{{flagg|isc|Myanmar|size=30px}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheJ' not found.{{flagg|isc|Myanmar|size=30x18px}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheJ' not found.{{flagg|isc|Myanmar|size=xs}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheJ' not found.{{flagg|isc|Myanmar|size=xl}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheJ' not found.{{flagg|isc|Myanmar|width=30|size=xs}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheJ' not found.{{flagg|isc|Myanmar|image=}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheJ' not found.{{flagg|isc|Myanmar|image=Flag of None.svg}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheJ' not found.{{flagg|isc|Myanmar|image=File:Flag of None.svg}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheJ' not found.Links and altvars:
{{flagg|psp|Egypt}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheE' not found.{{flagg|psf|Egypt}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheE' not found.{{flagg|psb|Egypt}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheE' not found.{{flagg|psb|Philippines|the=1}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheE' not found.{{flagg|csc|Egypt|section=History}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheE' not found.{{flagg|csb|Egypt|csection=History}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheE' not found.{{flagg|psb|Egypt|psection=Kingdom of Egypt (1922–1953)|variant=1922}}
→ Flag of Egypt{{flagg|psb|Egypt|plink=List of Egyptian flags}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheE' not found.{{flagg|psf|Egypt|pref=History of}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheE' not found.{{flagg|psp|Egypt|suff=at the Olympics}}
→ Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheE' not found.{{flagg|psp|Egypt|avar=fb}}
→ Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found.{{flagg|psp|Egypt|avar=football}}
→ Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found.{{flagg|psp|Egypt|avar=fbu|age=20}}
→ Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found.{{flagg|psf|Egypt|avar=navy}}
→ Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found.Non-existing data template:
{{flagg|isc|EUSSR|nodata=1}}
→ EUSSR{{flagg|isc|EUSSR|image=EUSSR red flag.svg|size=xl|nodata=1}}
→ EUSSRFor example:
Once you have a table with {{flaglist}} or other flag template 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.
Use a global find-and-replace in the wikitext. Replace:
with
The {{flagg}} template looks for the articles. If it finds one of the two choices it adds the link and an asterisk after the state, country, territory, or other subnational area name. If it does not find either article, it just adds the standard link.
Substitute your preferred topics in the pref= and pref2= spots. For more info see Help:Table and its sections on adding flags and country/state/territory links.
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. So only one big country table per article. Other country tables in the same article should use standard links.
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.
Template | Corresponding {{flagg}} syntax | Example |
---|---|---|
{{flag|country}} | {{flagg|uncb|country}} | {{flag|China}} → China{{flagg|unc|China}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found. |
{{flagbig|country}} | {{flagg|ulc|country|sz=l}} | {{flagbig|China}} → Andoza:Flagbig{{flagg|ulc|China|sz=l}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found. |
{{flagc|country}} | {{flagg|inc|country}} | {{flagc|China}} → Andoza:Flagc{{flagg|inc|China}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found. |
{{flagcountry|country}} | {{flagg|unce|country}} | {{flagcountry|CHN}} → Xitoy{{flagg|unce|CHN}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found. |
{{flagdeco|country}} | {{flagg|uxxo|country}} | {{flagdeco|China}} → {{flagg|uxx|China}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found. |
{{flagicon|country}} | {{flagg|cxxlo|country}} | {{flagicon|China}} → {{flagg|cxxlo|China}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found. |
{{flagicon image|image}} | {{flagg|uxx|image=image}} | {{flagicon image|Flag of China.svg}} → {{flagg|uxx|image=Flag of China.svg}} → |
{{flaglink|country|suffix}} | {{flagg|unp|country|suff=suffix}} | {{flaglink|China|at the Hopman Cup}} → Xitoy{{flagg|unp|China|suff=at the Hopman Cup}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found. |
{{flag+link|prefix|country}} | {{flagg|unp|country|pref=prefix}} (no existence check) | {{flag+link|Agriculture in|China}} → Andoza:Flag+link{{flagg|unp|China|pref=Agriculture in}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found. |
{{flaglist|country}} | {{flagg|usc|country}} | {{flaglist|China}} → China{{flagg|usc|China}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found. |
{{flagof|country}} | {{flagg|unp|country|sz=l}} | {{flagof|China}} → Andoza:Flagof{{flagg|unp|China|sz=l}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found. |
{{flagright|country}} | {{flagg|uncr|country}} | {{flagright|China}} → Andoza:Flagright{{flagg|uncr|China}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found. |
{{flagu|country}} | {{flagg|unu|country}} | {{flagu|China}} → China{{flagg|unu|China}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found. |
{{noflag|country}} | {{flagg|xnu|country}} | {{noflag|China}} → China{{flagg|xnu|China}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found. |
{{noflag|[[country]]}} | {{flagg|xnc|country}} | {{noflag|[[China]]}} → China{{flagg|xnc|China}} → Lua xatosi in package.lua at line 80: module 'Module:CountryData/cacheB' not found. |
The football templates are used as examples here; other sports that have separate templates work correspondingly.
Template | Corresponding {{flagg}} syntax | Example |
---|---|---|
{{fb|country}} | {{flagg|unpe|country|avar=fb}} | {{fb|China}} → Xitoy{{flagg|unpe|China|avar=fb}} → Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found. |
{{fb|country|align=1}} | {{flagg|uspe|country|avar=fb|al=c}} | {{fb|China|align=1}} → Andoza:Flaglink/aligned{{flagg|uspe|China|avar=fb|al=c}} → Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found. |
{{fb-big|country}} | {{flagg|ulpe|country|avar=fb|sz=l}} | {{fb-big|China}} → Xitoy {{flagg|ulpe|China|avar=fb|sz=l}} → Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found. |
{{fb-rt|country}} | {{flagg|unpre|country|avar=fb}} | {{fb-rt|China}} → Xitoy {{flagg|unpre|China|avar=fb}} → Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found. |
{{fbu|age|country}} | {{flagg|unpe|country|avar=fbu|age=age}} | {{fbu|17|China}} → Xitoy{{flagg|unpe|China|avar=fbu|age=17}} → Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found. |
{{fbw|country}} | {{flagg|unpe|country|avar=fbw}} | {{fbw|China}} → Xitoy{{flagg|unpe|China|avar=fbw}} → Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found. |
{{fbwu|age|country}} | {{flagg|unpe|country|avar=fbwu|age=age}} | {{fbwu|17|China}} → Xitoy{{flagg|unpe|China|avar=fbwu|age=17}} → Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found. |
{{army|country}} | {{flagg|unfe|country|avar=army}} (no automatic name override) | {{army|China}} → Andoza:Army{{flagg|unfe|China|avar=army}} → Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found. |
{{navy|country}} | {{flagg|unfe|country|avar=navy}} (no automatic name override) | {{navy|China}} → Xalq Harbiy dengiz kuchlarining Ozod Armiyasi{{flagg|unfe|China|avar=navy}} → Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found. |
{{air force|country}} | {{flagg|unfe|country|avar=air force}} (no automatic name override) | {{air force|China}} → Andoza:Air force{{flagg|unfe|China|avar=air force}} → Lua xatosi in package.lua at line 80: module 'Module:Flagg/Altvar data' not found. |
local titleSelf = mw.title.new(... or mw.getCurrentFrame():getTitle())local titleCountryData = mw.title.new[[Module:CountryData]]if titleSelf.isSubpage thenlocal sandbox = titleSelf.subpageText:match[[^sandbox]]if sandbox thentitleCountryData = titleCountryData:subPageTitle(sandbox)endendlocal CountryData = require(tostring(titleCountryData))local p = {}function p.main(frame)--Get input argumentslocal args = require('Module:Arguments').getArgs(frame,{valueFunc =function(key,value)if value thenvalue = mw.text.trim(value)--Change empty string to nil for all args except 'image' and 'border'if key=="image" or key=="border" or value~="" thenreturn valueendendreturn nilend})--Call main functionreturn p.luaMain(frame,args)endfunction p.luaMain(frame,args)local function emp2nil(x)if x=="" then return nil else return x endendlocal function space2emp(x)if string.find(x,"^%s*$") then return "" else return x endendlocal function nopx(x)if x~=nil and (string.find(x,"^%d+$") or string.find(x,"^%d+px$")) then return string.gsub(x,"^(.*)px","%1") else return nil endend--Country & mode parameterslocal mode = string.lower(args[1] or "usc")local mi = string.sub(mode,1,1)local ms = string.sub(mode,2,2)local mn = string.sub(mode,3,3)local me = string.sub(mode,4,-1)local country = args[2] or ""local avar = args["avar"] or args["altvar"]local clink = args["clink"] or args["link"]--Get country data & altvar datalocal data, alink, amap, asufif avar thenlocal age = args["age"] or ""local aaliasamap, aalias = require("Module:Flagg/Altvar data").alttable(age)avar = string.gsub(string.lower(avar or ""),"[ \-]","")avar = aalias[avar] or avarif not amap[avar] then error("Unknown avar") endlocal apar = {altvar=amap[avar].altvar;mw=amap[avar].mw;age=amap[avar].age;variant=args["variant"] or args[3]}data = CountryData.getcachedtable(frame, country, apar)asuf = amap[avar].altlinkalink = data["link alias-"..amap[avar].altvar] or (clink or data["shortname alias"] or data.alias or country).." "..asufelsedata = (args["nodata"] and {}) or CountryData.getcachedtable(frame, country, {variant=args["variant"] or args[3]})avar = ""amap = {[""]={altvar=""}}end--Name and link parametersclink = clink or data.alias or countrylocal pref = args["pref"]local suff = args["suff"] or asuflocal pref2 = args["pref2"]local suff2 = args["suff2"]if not pref and not suff then --Default prefixpref = "Flag of"endlocal yn_map = {[""]=0; ["0"]=0; ["no"]=0; ["n"]=0; ["1"]=1; ["yes"]=1; ["y"]=1}local fthe = (args["pthe"] and yn_map[args["pthe"]]~=0) or (args["the"] and yn_map[args["the"]]~=0)local nthe = (args["nthe"] and yn_map[args["nthe"]]~=0) or (args["the"] and yn_map[args["the"]]~=0)fthe = fthe and (pref and "t" or "T").."he " or ""nthe = nthe and (pref and "t" or "T").."he " or ""local flink = args["plink"] or args["flink"] or alink or clink=="" and "" or space2emp((pref or "").." ")..fthe..clink..space2emp(" "..(suff or ""))local flink2if args["plink2"] or args["flink2"] or pref2 or suff2 thenflink2 = args["plink2"] or args["flink2"] or clink=="" and "" or space2emp((pref2 or "").." ")..fthe..clink..space2emp(" "..(suff2 or ""))elseflink2 = flinkendlocal fsec = args["psection"] or args["section"]local fsec2 = args["psection2"] or args["section"]local csec = args["csection"] or args["section"]fsec = fsec and "#"..fsec or ""fsec2 = fsec2 and "#"..fsec2 or ""csec = csec and "#"..csec or ""if string.find(me,"f") thenif mw.title.new( flink ).exists == false thenif flink2 ~= flink and mw.title.new ( flink2 ).exists == true thenflink = flink2fsec = fsec2elseflink = clinkendendendlocal name = args["name"]if not name thenlocal cname = string.find(me,"e") and (data["name alias-"..amap[avar].altvar] or data["shortname alias"] or data.alias) or countryif mn == "f" thenname = cname=="" and "" or space2emp((pref or "").." ")..nthe..cname..space2emp(" "..(suff or ""))elsename = cnameendend--Image parameterslocal pimage = args["image"]local placeholder = "Flag placeholder.svg"local variant = args["variant"] or args[3] or ""local image_map = {[""]=placeholder; ["none"]=placeholder; ["blank"]=placeholder}if pimage then --Remove namespacepimage = string.gsub(pimage,"^[Ff][Ii][Ll][Ee]:","")pimage = string.gsub(pimage,"^[Ii][Mm][Aa][Gg][Ee]:","")endlocal iname = image_map[pimage] or pimagelocal size = args["size"] or args["sz"]local size_map = {xs="12x8px"; s="17x11px"; m="23x15px"; l="32x21px"; xl="46x30px"}if size==nil or string.find(size,"^%d*x?%d+px$") then--valid EIS size (..px, x..px or ..x..px) or unsetelseif string.find(size,"^%d*x?%d+$") then --EIS size without "px" suffixsize=size.."px"else --size from map, or invalid valuesize = size_map[size] or nilendlocal border = args["border"]if iname thensize = size or "23x15px"if yn_map[border]==0 then border = "" else border = "|border" endelseiname = data["flag alias-"..amap[avar].altvar.."-"..variant] or data["flag alias-"..variant] or data["flag alias-"..amap[avar].altvar] or data["flag alias"] or placeholdersize = size or emp2nil(data.size) or "23x15px"if border thenif yn_map[border]==0 then border = "" else border = "|border" endelselocal autoborder = data["border-"..variant] or data["border-"..amap[avar].altvar] or data.borderif autoborder and autoborder~="border" then border = "" else border = "|border" endendendlocal am = ""if args["alt"] or string.find(me,"a") thenam = args["alt"] or args["name"] or countryam = am.."|"..amend--Build display namelocal text = args["text"]if not text thenif mn=="x" then --no texttext = ""elseif mn=="p" or mn=="f" or mn == "*" then --prefix/suffix linktext = flink=="" and name or "[["..flink..fsec.."|"..name.."]]"-- By the principle of least surprise, there should be some-- indication that the link [[X of Country|Country]] does not-- go to [[Country]].if mn == "*" and clink ~= flink thentext = text:sub(1, -3) .. "\226\128\175*]]" endelseif mn=="b" then --both prefix/suffix and normal country linklocal preflink = pref and (flink=="" and pref.." " or "[["..flink..fsec.."|"..pref.."]] ") or ""local sufflink = suff and (flink=="" and " "..suff or " [["..flink..fsec.."|"..suff.."]]") or ""local namelink = (name=="" and "" or nthe)..(clink=="" and name or "[["..clink..csec.."|"..name.."]]")text = preflink..namelink..sufflinkelseif mn=="d" then --data templatelocal title = mw.title.new("Template:Country data "..country)--check if redirectif title.isRedirect thentext = "<span class=\"plainlinks\">["..title:fullUrl("redirect=no").." "..name.."]</span>"elsetext = "[["..title.fullText.."|"..name.."]]"endelseif mn=="u" then --unlinkedtext = nameelse --country link (default)text = clink=="" and name or "[["..clink..csec.."|"..name.."]]"endend--Build imagelocal ilink = args["ilink"]if not ilink thenif mi=="x" or (iname==placeholder and pimage~=placeholder) then --no image/invisible imageiname = placeholderborder = ""ilink = "|link="am = ""elseif mi=="i" then --image page linkilink = ""elseif mi=="c" then --country linkilink = "|link="..clink..(clink=="" and "" or csec)elseif mi=="p" or mi=="f" then --prefix/suffix linkilink = "|link="..flink..(flink=="" and "" or fsec)elseif mi=="d" then --data templatelocal title = mw.title.new("Template:Country data "..country)--check if redirectif title.isRedirect thenilink = "|link="..title:fullUrl("redirect=no")elseilink = "|link="..title.fullTextendelse --unlinked (default)ilink = "|link="endendif am == "" and string.find(me,"l") thenam = mw.ustring.sub(ilink,7,-1)endlocal image = "[[File:"..iname.."|"..size..border..ilink.."|alt="..am.."]]"if iname==placeholder thenif require('Module:yesno')(args["noredlink"]) == false theniname = ''image = "[[:Template:Country data "..country.."]]"endif (args["missingcategory"] or '') ~= '' thenimage = image..args["missingcategory"]endif string.find(me,"b") thentext = ''endend--Combine image and name with separatorlocal align_map = {left="left", l="left", center="center", centre="center", c="center", middle="center", m="center", right="right", r="right"}local align = align_map[args["align"] or args["al"]]local nalign = align_map[args["nalign"] or args["nal"]]local outif string.find(me,"r") then--image right of nameif (ms=="x" and mi=="x") or (string.find(me,"o") and iname==placeholder and pimage~=placeholder) then --name onlyout = textelseif ms=="x" then --no separatorout = text.."<span class=\"flagicon\">"..image.."</span>"elseif ms=="n" then --non-breaking spaceout = text.."<span class=\"flagicon\"> "..image.."</span>"elseif ms=="l" then --line breakout = text.."<span class=\"flagicon\"><br/>"..image.."</span>"elseif ms=="t" then --table cellout = "style=\"text-align:"..(nalign or "left").."\"|"..text.."||style=\"text-align:"..(align or "center")..";\"|<span class=\"flagicon\">"..image.."</span>"else --fixed-width span box (default)local width = args["width"] or args["w"] or require("Module:Flaglist").luawidth(size)out = text.." <span class=\"flagicon\" style=\"display:inline-block;width:"..width.."px;text-align:"..(align or "right")..";\">"..image.."</span>"endelse --image left of nameif (ms=="x" and mi=="x") or (string.find(me,"o") and iname==placeholder and pimage~=placeholder) then --name onlyout = textelseif ms=="x" then --no separatorout = "<span class=\"flagicon\">"..image.."</span>"..textelseif ms=="n" then --non-breaking spaceout = "<span class=\"flagicon\">"..image.." </span>"..textelseif ms=="l" then --line breakout = "<span class=\"flagicon\">"..image.."<br/></span>"..textelseif ms=="t" then --table cellout = "style=\"text-align:"..(align or "center")..";\"|<span class=\"flagicon\">"..image.."</span>||style=\"text-align:"..(nalign or "left").."\"|"..textelse --fixed-width span box (default)local width = nopx(args["width"] or args["w"]) or require("Module:Flaglist").luawidth(size)out = "<span class=\"flagicon\" style=\"display:inline-block;width:"..width.."px;text-align:"..(align or "left")..";\">"..image.."</span> "..textendendif string.find(me,"w") then --avoid wrappingout = "<span class=\"nowrap\">"..out.."</span>"end-- align in tableif me:find("t") thenout = 'style="text-align:'..(align or 'left')..'"|'..outend--Tracking categorieslocal cat = ""if pimage and not image_map[pimage] and country~="" and data["flag alias"] and not args.demo thencat = "[[Category:Pages using Flagg with specified image instead of data template image]]"endreturn out..catendreturn p