ينتج صورة صغيرة للعلم المسمى، بالإضافة إلى رابط ويكي للمقالة المرتبطة. لا تحتوي صورة الرمز على رابط (على عكس رمز العلم) حتى لا يعرض قارئو الشاشة الاسم مرتين.
على غرار علم، لكن اسم البلد المرتبط به غير موصول. يجب استخدام هذا القالب في المقالات ذات الصلة ب ويكيبيديا:دليل الأسلوب/وصلات (على سبيل المثال، عند استخدام نفس العلم عدة مرات في جدول واحد).
على غرار علم، لكنه يستخدم دائمًا نص العرض المفضل للمقالة المرتبطة بـ برابط الويكي. يكون مفيدًا عندما تكون معلمة الإدخال عبارة عن رمز بلد، أو اسم بلد طويل لأنه يرتبط بمقالة مختلفة، مثل بلد تاريخي.
يعرض علمًا للمعلمة المسماة بحجم "الأيقونة"، وهو حاليًا 23×15 بكسل بالإضافة إلى إطار بحجم بكسل واحد. هذا القالب مشابه جدًا لـ قالب:رمز علم، باستثناء أن الصورة غير مرتبطة بمقالة، أي أنها "زخرفية بحتة" وفقًا لـ إرشادات إتاحة محتوى الويب (WCAG) رابطة الشبكة العالمية (W3C). يمكن استخدام هذا القالب عندما يوفر نص المقالة المجاور للأيقونة مباشرةً الرابط المرتبط بالعلم.
لدى العديد من البلدان أيضًا قوالب أعلام فردية، تُستعمل باستخدام رموز الدول المكونة من ثلاثة أحرف لتقديم بدائل "مختصرة" للقوالب. وهذا سيف ذو حدين؛ فبعض رموز الدول (مثل "USA") معروفة على نطاق واسع وتوفر قوالب الاختصار (مثلا {{USA}}) سهولة في الاستخدام، ولكن بعض رموز الدول غامضة نسبيًا، لذا فمن المرجح أن تكون علامات الويكي أكثر وضوحًا إذا كُتبت أسماء الدول بالكامل. كما أن قوالب الاختصار لا توفر القدرة على استخدام مختلف أنواع الأعلام التاريخية (الموضحة أدناه) وبالتالي فهي أقل مرونة.
بالإضافة إلى القوالب المذكورة أعلاه، توجد قوالب أخرى كثيرة للأعلام. هذه القائمة (ربما غير مكتملة) تستبعد القوالب العسكرية (راجع #قوالب الأعلام العسكرية) والقوالب الرياضية (انظر #قوالب أعلام الفرق الرياضية الوطنية). راجع وثائق كل قالب لمزيد من التفاصيل.
يحدد المعامل (الموضعي) الأول لهذه القوالب البلد (أو أي كيان آخر) المراد استخدامه مع صورة العلم. تحدد هذه القوالب قوالب إضافية تخزن بشكل فردي معلومات خاصة بهذا البلد. على سبيل المثال، يتم تخزين اسم الصورة واسم المقالة الرئيسية المستخدمة مع {{علم|العراق}} (للحديث عن العراق) في قالب:بيانات بلد العراق. توجد المجموعة الكاملة من قوالب "بيانات البلد" هذه في تصنيف:قوالب بيانات بلد.
لاحظ أن هناك قوالب بيانات دول للعديد من الكيانات التي لا تعتبر دولًا، مثل المنظمات الدولية أو الكيانات دون الوطنية. إن استخدام كلمة دولة في أسماء هذه القوالب يرجع فقط إلى أن التنفيذ الأصلي لنظام قوالب العلم كان مبنيًا على قالب:علم - ربما كان من الأفضل أن يكون الاسم "بيانات علم"، ولكن من المحتمل أن يكون الوقت قد فات لإجراء هذا التغيير الآن.
توجد أيضًا العديد من قوالب بيانات الدول للدول التاريخية، ويمكن استخدامها لإنتاج الأعلام التاريخية مع روابط الويكي للمقالات المناسبة. ومن الأمثلة على ذلك:
لمزيد من السلاسة، يمكن التعرف على العديد من الأعلام من خلال اسم مستعار، عادةً ما يكون رمز للبلد مكون من ثلاثة أحرف. على سبيل المثال، بدلاً من {{رمز علم|السعودية}}، يمكن ببساطة استخدام {{رمز علم|KSA}} للوصول إلى .
Alias names are implemented as redirects in the template namespace. For example, Template:Country data VEN is a redirect to Template:Country data Venezuela. The complete set of these redirects is listed in Category:Country data redirects, and the available alias redirect(s) for a given country data template (if any) are also documented on that template's page.
Please do not create redirect aliases with uncommon abbreviations, especially for countries or regions that do not have standard country codes. Wikicode is much easier to read if the full name is used. Even some of the standard country codes are not widely known!
When using country code aliases, template flag will display this value for the wikilink's display text. For example:
Note that in each case, the target wikilink points to the correct article name (i.e. United States, United Kingdom, and People's Republic of China, respectively) but the display text matches the input parameter to template flag. This may be the desired effect, such as in column headings of a large table, but if the full name is wanted, then use Template:Flag country instead:
Many countries have had different flag variations at various periods in their history. The flag template system can accommodate this by storing multiple flag variants inside country data templates. A specific flag variant is selected by specifying an additional parameter to any of the standard flag templates. This parameter is usually given as the second positional parameter to the template, but may also be given as the variant named parameter.
The set of available flag variants (if any) for a specific country data template are documented on the country data template page itself. Each variant is identified by a short text label, such as empire or 1921 in the examples above. Usually, the label identifies the year in which the flag was introduced, but this is not a mandatory style convention.
Do not change the name of an existing flag variant label unless you are absolutely certain it is not in use. These labels are not like article names, where redirects are created when an article is renamed. Changing a flag variant label will instantly break any current usage of that label.
The default size for all flag icons created by these templates is 23x15px, with a one pixel border. That is, the icon will be no more than 23 pixels wide, and no more than 15 pixels tall. These dimensions were carefully chosen to generate the best results when flag icons are used in a bulleted list with the default browser text size. Some countries (mostly those with square or near-square flags) have different default sizes.
In certain situations, it might be desirable to use a larger (or smaller) size, and this is enabled with the size named parameter, available with all standard templates.
Displays the naval ensign of the named country (identified as the naval variant in the corresponding country data template) plus a wikilink to the main article for the country's navy. Note that the naval ensign for many countries is the same as the national flag. Also note that the WP:SHIPS and WP:MILHIST conventions are to use naval ensigns, not naval jacks when identifying ships with flag icons.
Displays the navy's flag of the named country (identified as the navy variant in the corresponding country data template) plus a wikilink to the main article for the country's navy. Note that this is the navy flag, which differs from the naval ensign, which for many countries is the same as the national flag. If the navy does not have a flag, the jack is used instead. Also note that the WP:SHIPS and WP:MILHIST conventions are to use naval ensigns, not navy flags when identifying ships with flag icons.
One of the most common instances of flag icon usage on Wikipedia is for national sport teams. Several sets of sport-specific templates have been developed to also use this flag template system and some have variant forms (see individual templates' documentation):
These templates have intentionally been given terse names because they tend to be used many, many times on individual pages for match results. They completely supersede a set of previously used national team-specific templates. For example, {{fb|ITA}} replaced {{ITAf}}, {{ru|NZL}} replaced {{NZLru}}{{cr|BGD}} replaced {{BCB}}, etc.
There are often several template variations available for a given sport:
with a "w" suffix, links to women's national team articles instead
with a "-rt" suffix, renders the flag icon to the right of the nation's name instead of to the left. This formatting style is often used in match results
with a -big" suffix, renders the flag icon in larger size and the team name underneath the flag. This formatting style is often used in tables of tournament results.
For example, for football, the following templates are used:
Users that do not like flag icons can disable them with a preference setting. A CSS class is used within the internal formatting template, and the class setting can be changed from a user's personal CSS file (skin-specific, cross-skin, or global).
There are three steps in each flag template invocation.
In the previous example of {{flag|Spain}}, the templates expand as follows:
First, Template:Flag expands to invoke Template:Country data Spain, and ensure that all user-specified parameters are set. The first parameter to the country data template is actually the name of the formatting template. This is the mechanism by which the same country data template can be used with multiple different formatting templates. Therefore, the first step of expansion results in:
{{country data Spain | flag/core | variant = | size = | name = Spain}}
If the variant (or second positional parameter), the size, and/or name parameters were specified in the user invocation, these would be set to the desired value. For example, {{flag|Spain|1939|name=España}} would expand to:
{{country data Spain | flag/core | variant = 1939 | size = | name = España}}
Next, the country data template expands to invoke the formatting template, plus add all the country-specific parameters. Going back to the simpler example of {{flag|Spain}}, the second expansion results in:
{{flag/core | alias = Spain | flag alias = Flag of Spain.svg | name = Spain}}
Lastly, the formatting template is expanded to produce:
<span class="flagicon">[[File:Flag of Spain.svg|23x15px|border |alt=|link=]] </span>[[Spain]]
The structure of all country data templates follows a standard pattern, which is extended to include additional parameters only when necessary.
The empty boilerplate for all country data templates is as follows:
{{ {{{1<noinclude>|country showdata</noinclude>}}}
| alias =
| flag alias =
| size = {{{size|}}}
| name = {{{name|}}}
}}
There are two essential values that must be specified:
The alias value identifies the name of the main article associated with the flag.
The flag alias value identifies the image name of the default flag.
The invocation of country showdata on the first line is used to automatically generate the template documentation, as described below.
The size = {{{size|}}} and name = {{{name|}}} statements ensure that any user-specified size and/or name values are passed through from the outer template (flag, flag icon, etc.) to the inner formatting template. Omission of these lines from the country data template would cause the size and name functionality to be disabled.
Additional flag variants are specified by individual flag alias statements. The unique label for the variant is the suffix of the parameter name, as flag alias-label (don't forget the hyphen). For example, Template:Country data Mexico has several flag variants, one of which is specified by:
| flag alias-1934 = Flag of Mexico (1934-1968).png
Therefore, when {{flag|Mexico|1934}} is transcluded, Image:Flag of Mexico (1934-1968).png is rendered. The selection of the flag variant is coded in the formatting templates.
Country data templates with at least one flag variant (in addition to the default) must also have the following line:
| variant = {{{variant|}}}
Similar to the size and name parameters as described above, this statement is required to pass the variant value (e.g. 1934) from the outer flag template to the inner formatting template. Omission of this line will cause the flag variant selection to fail.
If some flags are non-standard in shape and a 1px border is undesirable (for example for Nepal), then the border for the main flag may be defeated by adding the parameter
|border =
To remove the border for certain variant flags only, use the pattern |border-variant=, replacing variant with the respective variant label. For example:
Due to the coding of the flag templates, disabling the border for the main flag also automatically disables it for all flag variants. If the main flag should not have a border but any of the variants should, the respective |border-variant= parameters must be explicitly set to "border" to re-enable the 1px border:
The best results are obtained when the template name matches the article wikilink (as specified by the alias value). For example, Template:Country data Russia contains alias = Russia, which results in a target wikilink to Russia.
However, there are instances where the main article name contains a disambiguation string. For example, Template:Country data Georgia contains alias = Georgia (country). Therefore, {{flag|Georgia}} results in Georgia. Note that the wikilink is Georgia (country), but the display string is "Georgia", as expected.
In these instances, an additional statement is needed to support Template:Flag country properly. The shortname alias parameter should be set to the desired text string, such as shortname alias = Georgia. In effect, the resultant wikilink will be generated as [[alias|shortname alias]], or [[Georgia (country)|Georgia]] in this specific example.
The templates {{flaglink}} and {{flag+link}} append and prepend text to the link target, respectively. For example, to link to the education system in a table comparing different countries' educational outcomes, use
For link targets that do not start or end with the country name, use the {{flagdeco}} template (which returns an unlinked flag icon without text) followed by a standard wikilink:
Any country data template that will be used with a national team template must include an additional "pass-through" parameter:
| altlink = {{{altlink|}}}
This parameter is used to form the suffix of the associated wikilink. For example, Template:cr appends "national cricket team" to the country name (alias value), and this process is enabled by the altlink parameter.
In most cases, the flag and display name for national teams corresponds to the same flag and display name normally used for the nation. However, in some instances these can be over-ridden by additional parameters within the country data template. The default wikilink can also be changed in cases where the common naming convention is not used.
In many sports, all-Ireland teams compete with athletes from both the Republic of Ireland and Northern Ireland, and often under unique flags for each sport. Template:Country data Ireland includes unique flags for several sports teams, such as flag alias-field hockey = Flag of Ireland hockey team.svg, so that {{fh|Ireland}} produces أيرلندا
In each of these examples, the over-ride parameter (name alias-football, flag alias-field hockey, or link alias-netball) is identified by a unique per-sport variable that is passed from the appropriate sport team template. For example, Template:fb includes altvar = football. Therefore, any country data template that utilizes one or more team sport over-ride parameters must also include:
Country data templates "self-document" themselves through Template:Country showdata. Recall that the first line of each country data template is an invocation to a formatting template, defaulting to country showdata if that parameter is missing:
For simple country data templates, nothing further needs to be done to document them. If any flag variants, redirect aliases, etc. are used with the template, they are documented by adding parameters specifically for use by country showdata. These extra parameters are enclosed in a <noinclude>....</noinclude> section as they should not be present for any other invocation of the country data template.
Pages with many flag icons may come close to or exceed Wikipedia's post-expand include size limit. In these cases consider using modules or module-wrapper templates instead:[
Module:Flagg is a Scribunto module that reads existing country data templates and can produce a wide variety of outputs to replicate most existing flag templates. It can be invoked directly or used via {{Flagg}} (although the latter doubles the post-expand include size). See the documentation at Template:Flagg/doc for usage.
Module:Flag is a wrapper for Module:Flagg that provides shortcuts to replace several common flag templates:
{{Coat of arms}} for coats of arms in infoboxes and lists
{{flag IOC}} for a similar template used exclusively for Olympic Games related articles, and uses a different internal mechanism than for these templates.
{{Shipboxflag}} for display of flags in ship infoboxes