Template:Engvar/doc
This is a documentation subpage for Template:Engvar. It contains usage information, categories, interlanguage links and other content that is not part of the original template page. |
Usage
[सम्पादन]This template can be used in templates that are used on pages with different English language variants (see ENGVAR): articles in en-UK and articles in en-US. At the moment only UK and US English are recognised.
Article editor: When using the prepared template in an article, the editor can set its parameter
. The template text now will use the provided en-UK variant of words. This parameter setting is only needed once in the template.
|engvar=en-UK
In the template: So your template takes input parameter
as the language id. Internally, your template should have this code construct:
{{{engvar}}}
... | label= {{engvar| engvar={{{engvar}}} | en-uk=Football | en-us=Soccer }} ...
Depending on the engvar input, it returns one of the words.
Language id
[सम्पादन]At this moment, the next language ids are recognised.
These ased in article code (article editor; case insensitive):
language | alternative name | note |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
default |
Used in template code (template editor):
- Here, always use the lowercase language id for your word definition:
(NOTuk-en=Football
)uk-EN=Football
- Recognised language id's:
. Abbreviations like "uk" can not be used to define a word.en-uk=, en-us=, en-aus=, en-nz=, en=
Unnamed parameters
[सम्पादन]In template code unnamed parameters can be used:
- Unnamed parameter 1=pass throught the
variable. Named:{{{engvar}}}
engvar={{{engvar}}}
- Unnamed parameter 2=en-UK word(s)
- Unnamed parameter 3=en-US word(s)
- Unnamed parameter 4=en-AUS word(s)
- Unnamed parameter 5=en-NZ word(s)
- Parameter "en=" cannot be unnamed.
<!-- The next four rows are equal in template code: --> ... | label= {{engvar| engvar={{{engvar|}}} | en-uk=Football | en-us=Soccer }} | label= {{engvar| 1={{{engvar|}}} | uk=Football | us=Soccer }} | label= {{engvar| {{{engvar|}}} | Football | Soccer }} | label= {{engvar| 1={{{engvar|}}} | 2=Football | 3=Soccer }} ...
Plain "en" variant
[सम्पादन]It is possible to define and use the plain English variant word(s) with id "en":
. From here, the article can ask for plain "en" by using en=Association football
.
engvar=en
In the template code, this must always be a named parameter.
... | label= {{engvar| {{{engvar|}}} | Football | Soccer | en=Association football }} ...
Default language id
[सम्पादन]Default behaviour 1: To force a default language id (a language that will be used when there is no input, or a blank input) use
.
default=en-US
| label= {{engvar| {{{engvar}}} | Football | Soccer | default=en-US }}
Default behaviour 2: Another default-behaviour can be used: in your template, provide parameter
with a default language id:
engvar
| label= {{engvar| {{{engvar| en-US }}} | Football | Soccer | en=Association football }}
This default last example will not use the default language when the engvar is a blank. Instead, the standard default word is returned (see below).This may occur in nested templates and pass-through variables.
Default word(s)
[सम्पादन]Default behaviour 3:
When the
value is not recognised (or the engvar
language alternative you might have provided), then the default word(s) will be returned.
default
This default word(s) is determined as follows:
1st: the
word if entereden=
2nd: the
word if entereden-uk=
3rd: the
word if entereden-us=
4rd: the
word if entereden-aus=
5rd: the
word if entereden-nz=
6rd: a blank
Clearly, this template tries to make a catch when possible. Blanks output avoided when possibble.
Default behaviour 4: From the above, it follows that entering
produces the default word(s) as described. This is intentionally and by definition. Still, it is preferred not to rely on this route, because it might not work as expected.
engvar=en
Notes on coding
- On the template side provide at least both UK and US word(s), and maybe the en-word(s). Do not rely on the Default-behaviour, even when it tests OK today.
- Use named parameters for code clarity
- Do not rely on blank entries to return (do not use:
). It might be interpreted as absent, and so another word may be used.en-UK=|...}}
Full parameter list
[सम्पादन]Parameter list:
{{engvar | engvar = | en-uk = | en-us = | en-aus = | en-nz = | en = | default= }}
Or, unnamed:
{{engvar | | | | | | en = | default= }}
Todo
[सम्पादन]- Other English variants could be added
- Is there a definite list of English language variants, we should cover?
- Maybe a fallback can exist: if en-GB does not exist then use en-UK
- Rewrite this doc. ;-)
Examples
[सम्पादन]en-UK | en-US | en-CAN en-OED (Oxford) |
en-AUS en-NZ |
---|---|---|---|
centre | center | centre | centre |
colour | color | colour | colour |
-isation | -ization | -ization | -isation |
vapour | vapor | vapour | vapour |
grey | gray | grey | grey |
See also
[सम्पादन]- WP:ENGVAR about using a single variant in an article
- Template:British English for the talk-page banner for articles written in British English
- Template:American English for the talk-page banner for articles written in American English