This is a documentation subpage for Template:Engvar. It contains usage information, categories and other content that is not part of the original page. |
This template is used on many pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
This template uses Lua: |
This template is used inside other templates. It allows templates to show national varieties of English, when |engvar=
is passed by each article.
For example, one template can display "football" for |engvar=en-UK
articles, and "soccer" for |engvar=en-US
articles.
Usage
- Articles specify the English variety parameter for relevant templates like
{{example|engvar=en-US}}
. They do not use{{engvar}}
. - Templates use
{{engvar}}
. It should not forget to pass-through|engvar={{{engvar|}}}
...
| label3 = {{engvar |defaultWord=Colour |defaultLang=en-UK |en-US=Color |engvar={{{engvar|auto}}} }}
| data3 = {{{color|}}}
| label4 = {{engvar |defaultWord=Football |defaultLang=en-UK |en-US=Soccer |engvar={{{engvar|auto}}} }} team
| data4 = {{{team|}}}
...
The |defaultWord=
be shown by default. But if an article asks for an English variety that has a corresponding parameter specified in the template, the value will be shown.
In the example, the template specified a British English word as default whenever no |engvar=
is specified by the article. The word can be changed in an American English article by that article specifying |engvar=en-US
. The fallback 'auto' value means it will try to determine the language based on templates like {{Use British English}} or {{Use American English}} being present on the page if no engvar is specified.
Note: {{engvar}}
is unrelated to parameter names like |color=
vs. |colour=
. See programming option |data3={{{color|{{{colour|}}} }}}
Example
Consider an example template, a fictive {{infobox personal likes}}. The demo is encoded in {{Engvar/doc/infobox demo}}.
Template code
<strong class="error"><span class="scribunto-error" id="mw-scribunto-error-ea9089f8">Script error: No such module "DecodeEncode".</span></strong>
Three articles
A live example
Currently, {{infobox element}} has five {{engvar}} words. Phosphorus shows |engvar=en-UK
despite the |engvar=en-US
default.
Parameter list
Template
[[:Template:((]]engvar
<strong class="error"><span class="scribunto-error" id="mw-scribunto-error-ea9089f8">Script error: No such module "DecodeEncode".</span></strong>
Article
{{example
| engvar =
| engvarCat =
}}
List of English varieties
In the template, use the exact ISO-code as the parameter name like |en-GB=vapour
. Write |en-US=soccer
not |American English=soccer
. Needed varieties have articles using the template and words differing from the default.
English variety | ISO-code |
---|---|
American English | en-US
|
Australian English | en-AU
|
British English | en-GB
|
Canadian English | en-CA
|
Hiberno-English (Irish-English) | en-EI
|
Hong Kong English | en-HK
|
Indian English | en-IN
|
Jamaican English | en-JM
|
Malawian English | en-MW
|
New Zealand English | en-NZ
|
Nigerian English | en-NG
|
Pakistani English | en-PK
|
Philippine English | en-PH
|
Scottish English | en-SCO
|
Singapore English | en-SG
|
South African English | en-ZA
|
Trinidadian English | en-TT
|
British English Oxford spelling British (Oxford) English Oxford English Dictionary (OED) |
en-OED
|
IUPAC spelling | en-IUPAC
|
There is backwards compatibility for leeway in articles. |engvar=en-US
, |engvar=United States
, |engvar=US
can all show the |en-US=football
variety.
Maintenance category
Articles with an invalid |engvar=
will be placed in the hidden maintenance category Category:Articles using an unknown Template:Engvar option. Articles listed may need editing.
An article's requested |engvar=
may be unspecified in the template. For example, if an article uses {{example|engvar=South African English}}
but the template has no |en-ZA=
, then the template will return |defaultWord=default color name
. The category will not be used.
- When this categorization is not desired for a whole template, set
|engvarCat=no
in the template - Otherwise pass-through this setting from the article:
|engvarCat={{{engvarCat|yes}}}
. This allows the editor to switch categorization off per article.
Articles are sorted by |engvarCatSort=
or Template:Magic word by default. Note that other templates will fill this category. Set this parameter like |engvarCatSort=Personal prefs
in a template to group its listings under "P".
Template data
No description.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Default spelling | defaultword | The default word, usually the word in the English variety most often used
| String | suggested |
Default English variety | defaultLang | Adding this helps document your {{engvar}} setting
| String | suggested |
English variety | engvar | English variety to use. Set to 'auto' to try to detect variety based on templates such as {{Use British English}} or {{EngvarB}} being present on the page.
| String | required |
Suppress maintenance category | engvarCat | no description
| String | suggested |
Fallback | fallback | Whether Commonwealth English languages should fallback to en-GB if not specified
| Boolean | optional |
Maintenance category sort key | engvarCatSort | no description
| String | optional |
American English spelling | en-US | no description
| String | optional |
Australian English spelling | en-AU | no description | String | optional |
British English spelling | en-GB | no description | String | optional |
Canadian English spelling | en-CA | no description | String | optional |
Hiberno-English (Irish-English) spelling | en-EI | no description | String | optional |
Hong Kong English spelling | en-HK | no description | String | optional |
Indian English spelling | en-IN | no description | String | optional |
Jamaican English spelling | en-JM | no description | String | optional |
Malawian English spelling | en-MW | no description | String | optional |
New Zealand English spelling | en-NZ | no description | String | optional |
Nigerian English spelling | en-NG | no description | String | optional |
Pakistani English spelling | en-PK | no description | String | optional |
Philippine English spelling | en-PH | no description | String | optional |
Scottish English spelling | en-SCO | no description | String | optional |
Singapore English spelling | en-SG | no description | String | optional |
South African English spelling | en-ZA | no description | String | optional |
Trinidadian English spelling | en-TT | no description | String | optional |
British (Oxford) English spelling | en-OED | no description | String | optional |
IUPAC spelling | en-IUPAC | no description | String | optional |
See also
- HELP:ENGVAR
- Category:Articles using an unknown Template:Engvar option
- ISO 3166-1 alpha-2 -- The 2-letter country code
- Template:Ml - debugging