Module:Flag
- Afrikaans
- العربية
- Авар
- বাংলা
- བོད་ཡིག
- Bosanski
- Chavacano de Zamboanga
- Corsu
- Cymraeg
- ཇོང་ཁ
- فارسی
- Gĩkũyũ
- Hausa
- हिन्दी
- Íslenska
- ಕನ್ನಡ
- Kapampangan
- ქართული
- Ikinyarwanda
- Ladino
- Lombard
- Magyar
- मैथिली
- مازِرونی
- ꯃꯤꯇꯩ ꯂꯣꯟ
- Монгол
- မြန်မာဘာသာ
- नेपाली
- 日本語
- ଓଡ଼ିଆ
- Oʻzbekcha / ўзбекча
- ਪੰਜਾਬੀ
- پښتو
- Tok Pisin
- Setswana
- සිංහල
- Simple English
- سنڌي
- کوردی
- தமிழ்
- Taclḥit
- တႆး
- ไทย
- Tyap
- Українська
- اردو
- Tiếng Việt
- Winaray
- Yorùbá
- 中文
- Bajau Sama
Appearance
From Wikipedia, the free encyclopedia
This module is rated as beta. It is considered ready for widespread use, but as it is still relatively new, it should be applied with some caution to ensure results are as expected.
Page template-protected This module is currently protected from editing.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
Warning This Lua module is used on approximately 358,000 pages .
To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them.
To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them.
This module depends on the following other modules:
Lua-native alternative to popular flag templates. Can be used to reduce post-expand include size of pages with lots of templates, since it avoids calling multilevel templates.
Usage
Generic flag templates
- {{flag }} → {{#invoke:flag|}}
- {{flag country }} → {{#invoke:flag|country}}
- {{flag decoration }} (or {{flagdeco }}) → {{#invoke:flag|decoration}} (or {{#invoke:flag|deco}})
- {{flag icon }} → {{#invoke:flag|icon}}
- {{flag link }} → {{#invoke:flag|link}}
- {{flag+link }} → {{#invoke:flag|+link}}
- {{flag list }} → {{#invoke:flag|list}}
Sports flag templates
- {{flag athlete }} → {{#invoke:flag|athlete}}
- {{flag medalist }} → {{#invoke:flag|medalist}}
- {{flag team }} → {{#invoke:flag|team}}
- {{flag IOC }} → {{#invoke:flag|IOC}}
- {{flag IOC 2 }} → {{#invoke:flag|IOC 2}}
- {{flag IOC athlete }} → {{#invoke:flag|IOC athlete}}
- {{fb }} → {{#invoke:flag|fb}}
- {{fba }} → {{#invoke:flag|fba}}
- {{fb-rt }} → {{#invoke:flag|fb-rt}}
- {{fbicon }} → {{#invoke:flag|fbicon}}
- {{fbaicon }} → {{#invoke:flag|fbaicon}}
- {{ru }} → {{#invoke:flag|ru}}
Examples
| Template | Module | ||||
|---|---|---|---|---|---|
| Code | Output | PEIS | Code | Output | PEIS |
{{flag|CHN}} |
CHN | 443b | {{#invoke:flag||CHN}} |
CHN | 128b |
{{flag country|CHN}} |
China | 577b | {{#invoke:flag|country|CHN}} |
China | 128b |
{{flag decoration|CHN}}/{{flag deco|CHN}} |
452b | {{#invoke:flag|decoration|CHN}}/{{#invoke:flag|deco|CHN}} |
107b | ||
{{flag icon|CHN}} |
China | 548b | {{#invoke:flag|icon|CHN}} |
China | 117b |
{{flag link|CHN|at the 2004 Summer Olympics}} |
China | 497b | {{#invoke:flag|link|CHN|at the 2004 Summer Olympics}} |
China | 198b |
{{flag+link|History of|CHN}} |
China | 663b | {{#invoke:flag|+link|History of|CHN}} |
China | 139b |
{{flag list|SWI}} |
SWI | 685b | {{#invoke:flag|list|SWI}} |
SWI | 254b |
{{flag team|GBR}} |
Great Britain (GBR) | 804b | {{#invoke:flag|team|GBR}} |
Great Britain (GBR) | 193b |
{{flag athlete|Andy Murray|GBR}} |
Andy Murray (GBR) | 617b | {{#invoke:flag|athlete|Andy Murray|GBR}} |
Andy Murray (GBR) | 210b |
{{flag medalist|Andy Murray|GBR}} |
Andy Murray Great Britain |
469b | {{#invoke:flag|medalist|Andy Murray|GBR}} |
Andy Murray Great Britain |
129b |
{{flag IOC|CAN|1924 Winter|1}} |
Canada (1) | 326b | {{#invoke:flag|IOC|CAN|1924 Winter|1}} |
Canada (1) | 163b |
{{flag IOC 2|HKG|1954 Asian Games|1}} |
Hong Kong (1) | 368b | {{#invoke:flag|IOC 2|HKG|1954 Asian Games|1}} |
Hong Kong (1) | 184b |
{{flag IOC athlete|Mark Spitz|USA|1972 Summer}} |
Mark Spitz (USA) | 346b | {{#invoke:flag|IOC athlete|Mark Spitz|USA|1972 Summer}} |
Mark Spitz (USA) | 178b |
{{fb|CHN}} |
China | 560b | {{#invoke:flag|fb|CHN}} |
China | 151b |
{{fb-rt|CHN}} |
China | 482b | {{#invoke:flag|fb-rt|CHN}} |
China | 151b |
{{fbicon|CHN}} |
China | 444b | {{#invoke:flag|fbicon|CHN}} |
China national football team | 163b |
{{fba|CHN}} |
China | 625b | {{#invoke:flag|fba|CHN}} |
China | 149b |
{{fbaicon|CHN}} |
China | 500b | {{#invoke:flag|fbaicon|CHN}} |
Chinese Football Association | 159b |
{{ru|CHN}} |
China | 646b | {{#invoke:flag|ru|CHN}} |
China | 210b |
Caveats
When used inside a template, parameters from that template are passed to the module. This can be useful in some situations, but can lead to conflicts (for example, if the parent template has a parameter |country= that is unrelated to the flag it is supposed to display). To prevent this behavior, add the |frameonly= parameter to the module call, e.g. {{#invoke:flag|deco|CHN|frameonly=true}}.
The above documentation is transcluded from Module:Flag/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (edit) pages.
Subpages of this module.
Editors can experiment in this module's sandbox (edit | diff) and testcases (edit) pages.
Subpages of this module.
localmargs=require('Module:Arguments') localfunction_main(frame,name,mode,key) localcategories={ ['Flag icon']='[[Category:Flag icons missing country data templates]]{{Preview warning|unrecognized country in Template:flag icon}}', ['Flag decoration']='[[Category:Flag decoration missing country data templates]]', } localyesno=require('Module:Yesno') --Get input arguments localargs=margs.getArgs(frame,{ frameOnly=((frame.args.frameonlyor'')~=''),valueFunc= function(argkey,value) ifvaluethen value=mw.text.trim(value) --Change empty string to nil for all args except 'image' and 'border' ifargkey=="image"orargkey=="border"orvalue~=""then returnvalue end end returnnil end }) localpreftext,sufftext="","" ifname=='Flag+link'then args.pref=args[1] elseifname=='Flag athlete'then args.preftext=args[1] args[2]=args.codeorargs[2]or"" args.variant=args.variantorargs[3] elseifname=='Flag medalist'then preftext=(args[1]or"").."<br/>" args[2]=args.codeorargs[2]or"" args.variant=args.variantorargs[3] elseifname=='Flag link'then args.suff=args[2] args[2]=args[1]or"" args.variant=args.variantorargs[3] elseifkey~=nilthen args.variant=args.variantorargs[1] args[2]=key else sports={ ['3x3']='3x3', bb='bb', fb='fb', ['fb-rt']='fb', fbicon='fb', ru='ru', fba='fba', fbaicon='fba' } ifsports[name]then args.avar=args[1]andsports[name]ornil ifname=='fb'andyesno(args.align)==truethen args.align='c' elseifsports[name]=='fba'then ifargs[1]then locallist=require("Module:Fba/list") localold=((args.oldor"")~="")and"_old"or"" localcountry=args[1] localfba=list.fbas[country..old] ifnotfbathen-- look for aliases localcountryTable=require('Module:CountryData').getcachedtable(frame,country) ifcountryTableandcountryTable.aliasthen country=countryTable.alias fba=list.fbas[country..old] end end ifargs.name=="code"then args.name=list.codes[country]orcountry elseifargs.name=="full"then args.name=fba end iffbathen mode=string.gsub(mode,"p","c") args.link=fba end args.altlink=args.old elseifargs.name=="code"orargs.name=="full"then args.name="" end end elseifname=="Flag team"and(args.codeorargs[1])then sufftext=' <span style="font-size:90%;">('..(args.codeorargs[1])..')</span>' end args.variant=args.variantorargs[2] args[2]=args[1]or"" end args[1]=mode..(args.optsor'') args.missingcategory=categories[name] args.noredlink=args.noredlinkor'notext' ifargs.placeholderandyesno(args.placeholder)~=truethen args[1]=args[1]..'o' end check='' ifname=='Flag icon'andmw.title.getCurrentTitle().namespace==0then localunknown='[[Category:Pages using '..mw.ustring.lower(name).. ' template with unknown parameters|_VALUE_'..frame:getParent():getTitle()..']]' localopts={ unknown=unknown, preview='Page using [[Template:'..name..']] with unknown parameter "_VALUE_"', ignoreblank='y', '1','2','variant','image','size','sz','border','align','al','width', 'w','alt','ilink','noredlink','missingcategory','name','clink','link', 'pref','suff','plink','the','section','altvar','avar','age','nalign', 'nal','text','nodata','opts','placeholder','getParent','frameonly' } check=require('Module:Check for unknown parameters')._check(opts,args) end returnpreftext..require('Module:Flagg').luaMain(frame,args)..sufftext..check end localp={ ['']=function(frame)return_main(frame,'Flag','unc')end, decoration=function(frame)return_main(frame,'Flag decoration','uxx')end, icon=function(frame)return_main(frame,'Flag icon','cxxl')end, link=function(frame)return_main(frame,'Flag link','unpe')end, ['+link']=function(frame)return_main(frame,'Flag+link','unpefo')end, country=function(frame)return_main(frame,'Flag country','unce')end, list=function(frame)return_main(frame,'Flag list','usc')end, team=function(frame)return_main(frame,'Flag team','unce')end, athlete=function(frame)return_main(frame,'Flag athlete','unape')end, medalist=function(frame)return_main(frame,'Flag medalist','unce')end, ['3x3']=function(frame)return_main(frame,'3x3','unpe')end, bb=function(frame)return_main(frame,'bb','unpe')end, fb=function(frame)return_main(frame,'fb','unpe')end, fba=function(frame)return_main(frame,'fba','unpe')end, ['fb-rt']=function(frame)return_main(frame,'fb-rt','unpre')end, fbicon=function(frame)return_main(frame,'fbicon','pxxl')end, fbaicon=function(frame)return_main(frame,'fbaicon','pxxl')end, ru=function(frame)return_main(frame,'ru','unpe')end, IOC=function(frame)returnrequire('Module:Country_alias').flagIOC(frame:newChild{title='Template:Flag IOC'})end, IOC2=function(frame)returnrequire('Module:Country_alias').flagXYZ(frame:newChild{title='Template:Flag IOC 2',args={name=margs.getArgs(frame).nameor'',type='name'}})end, IOCathlete=function(frame)returnrequire('Module:Country_alias').flagXYZ(frame:newChild{title='Template:Flag IOC athlete',args={type='athlete-O'}})end, } p['deco']=p.decoration p['IOC 2']=p.IOC2 p['IOC athlete']=p.IOCathlete returnsetmetatable(p,{['__index']=-- returns table p with the metatable __index set so that, if the table KEY isn't recognized, it returns function(_,key)-- this anonymous function called as function(p, KEY) returnfunction(frame)return_main(frame,'Flag','unc',key)end-- which interprets the module call as {{flag|KEY}} and passes it to _main() end })