Template:Currency/doc#Error messages
{{Documentation subpage}}
{{High-use}}
{{lua|Module:Currency|Module:Currency/Presentation}}
{{Lua sidebar}}
Formats a currency value with the appropriate symbol which is linked to the article about the currency. If no currency is specified, the template will show the amount in United States dollars.
Usage
Using unnamed parameters:
:
Using named parameters:
:
where:
:{{var|value}} is a number with or without comma separators; may be followed by an optional quantifier: 'thousand', 'million', 'M', 'billion', 'B', or 'trillion'.
:{{var|code}} is an ISO 4217 currency code or one of the supported non-standard codes listed below.
:{{para|first}} when set to any value produces a long-form currency name
:{{para|linked}} when set to no
disables wikilinks on the rendered currency symbol or long-form currency name
:{{para|fmt}} specifies how {{var|value}} digit-groups are separated:
::commas
(default) separates {{var|value}} digit-groups with commas; this is the default, same as when {{para|fmt}} is empty or omitted
::gaps
separates {{var|value}} digit-groups with narrow gaps.
::none
renders {{var|value}} without digit grouping.
:{{para|passthrough}} specifies whether or not the template should attempt to parse the number according to {{para|fmt}} or just put whatever string is provided in {{para|amount}} directly after the currency sign. Should have value of either {{para|passthrough|yes}} or {{para|passthrough|no}}
When using parameter names, {{para|amount}} and {{para|code}} are preferred. The template will also accept {{para|Amount}} and {{para|type}} and {{para|Type}} though.
Note: Using both named and unnamed parameters may produce unexpected results. In this example, the template expects the first unnamed parameter to be a value number:
::
:::{{Currency|amount=1000|GBP}}
::use
or
, which both yield {{Currency|amount=1000|code=GBP}} .
Supported non-standard currency codes
=Codes that can be translated to ISO 4217 currencies=
These non-standard codes are aliases of standard ISO 4217 codes.
{{Div col|colwidth=15em}}
- EGE
- EU
- EURO
- FRW
- KSH
- NEP
- POUND
- POUND STERLING
- RMB
- STERLING
- STG
- TSH
- UK
- UNITED STATES
- US
- U.S.
- USA
- USH
{{Div col end}}
=Other non-standard codes=
These codes either do not have a matching ISO 4217 currency code or are alternate versions of existing ISO 4217 codes or support unique aspects of a currency.
- BITCOIN – no matching ISO 4217 code
- BTC – no matching ISO 4217 code
- DKK2 – alternate version of DKK
- FRF – historical
- GRD – historical
- LSL2 – plural version of LSL
- LTL – historical
- NOK2 – alternate version of NOK
- SEK2 – alternate version of SEK
- SZL2 – plural version of SZL
- US$ - special case: like the standard codes "USD" (and "$"), but only displays "$" instead of the longer "US$" (for articles where displaying "US$" might appear inappropriately long, but the template should still link to "United States dollar" to avoid any ambiguity)
- XBT – no matching ISO 4217 code
Examples
Currencies other than the United States dollar can be rendered by using the appropriate ISO 4217 currency code
gives: {{Currency|1000|BMD}} for the Bermudian dollar{{Currency|1000|BMD}}
gives: {{Currency|1000|BDT}} for the Bangladeshi taka{{Currency|1000|BDT}}
gives: {{Currency|1000|AMD}} for the Armenian dram{{Currency|1000|AMD}}
Some of the more well known currencies also provide the ability to use common abbreviations or full names.
gives: {{Currency|1000|us}}{{Currency|1000|US}}
gives: {{Currency|1000|United States}}{{Currency|1000|United States}}
gives: {{Currency|1,000|JPY}}{{Currency|1,000|JPY}}
Parameter names can also be used, if preferred:
gives: {{Currency|amount=1000|code=US}}{{Currency|amount=1000|code=US}}
gives: {{Currency|1000|code=euro}}{{Currency|1000|code=euro}}
Negative amount:
gives: {{Currency|amount=-1000|code=US}}{{Currency|amount=-1000|code=US}}
Text quantifiers:
gives: {{Currency|1000 million|code=euro}}{{Currency|1000 million|code=euro}}
gives: {{Currency|1000M|code=euro}}{{Currency|1000M|code=euro}}
The first use of a currency should show the value and the full name of the currency, so if the "first" parameter is defined then that is what will be given.
gives: {{Currency|1000|cve|first=yes}}{{Currency|1000|cve|first=yes}}
gives: {{Currency|1000|cve}}{{Currency|1000|cve}}
Because the symbol for the currencies DKK, NOK, and SEK may be ambiguous, these may be represented in two ways:
- For DKK:
- :
gives: {{Currency|1000|dkk}}{{Currency|1000|dkk}} - :
gives: {{Currency|1000|dkk2}}{{Currency|1000|dkk2}} - For NOK:
- :
gives: {{Currency|1000|NOK}}{{Currency|1000|NOK}} - :
gives: {{Currency|1000|NOK2}}{{Currency|1000|NOK2}} - For SEK:
- :
gives: {{Currency|1000|SEK}}{{Currency|1000|SEK}} - :
gives: {{Currency|1000|SEK2}}{{Currency|1000|SEK2}}
Similarly, some currencies use different symbols for single and plural amounts:
- :
gives: {{Currency|1|LSL}}{{Currency|1|LSL}} - :
gives: {{Currency|1000|LSL2}}{{Currency|1000|LSL2}} - ::The template does not currently make this distinction automatically so it is the responsibility of the editor using these kinds of codes to get the code right.
Digit grouping:
- {{para|fmt|commas}}
- :
gives: {{Currency|1000 million|code=euro|fmt=commas}}{{Currency|1000 million|code=euro|fmt=commas}} - {{para|fmt|gaps}}
- :
gives: {{Currency|1000 million|code=euro|fmt=gaps}}{{Currency|1000 million|code=euro|fmt=gaps}} - {{para|fmt|none}}
- :
gives: {{Currency|1000 million|code=euro|fmt=none}}{{Currency|1000 million|code=euro|fmt=none}}
Passthrough:
- {{para|passthrough|yes}}
- :
gives: {{Currency|6 million|PHP|passthrough=yes}}{{Currency|6 million|PHP|passthrough=yes}} - :
gives: {{Currency|6 trillion|PHP|passthrough=yes}}{{Currency|6 trillion|PHP|passthrough=yes}} - :
gives: {{Currency|6 tn|PHP|passthrough=yes}}{{Currency|6 tn|PHP|passthrough=yes}} - {{para|passthrough|no}}
- :
gives: {{Currency|6 million|PHP|passthrough=no}}{{Currency|6 million|PHP|passthrough=no}} - :
gives: {{Currency|6 trillion|PHP|passthrough=no}}{{Currency|6 trillion|PHP|passthrough=no}} - :
gives: {{Currency|6 tn|PHP|passthrough=no}} (error expected, as template doesn't know how to parse {{code|6 tn}} to {{code|6,000,000,000,000}}){{Currency|6 tn|PHP|passthrough=no}} - Use sparingly! Usually you want {{para|fmt}} instead. {{para|passthrough}} should only be used in ways compatible with MOS:CURRENCY.
Error messages
{{tld|currency}} can produce several error message. These are:
{{currency}} – invalid code – the value in the second unnamed parameter or assigned to {{para|code}} cannot be found in the template's list of codes. Make sure that the assigned code is a correct ISO 4217 currency code or one of the supported non-standard codes listed above.{{currency}} – invalid amount – the value in the first unnamed parameter or assigned to {{para|amount}} contains one or more characters that is not a minus sign, a digit, comma, or decimal point, or has some text that is not one of the permitted quantifiers. Make sure that comma separators group three digits and that the number has only one decimal point. Make sure that the amount and code parameters are either both named ({{para|amount}} and {{para|code}}) or both unnamed.{{currency}} – definition missing position – an internal error that should only occur when an editor is mucking about in Module:Currency/Presentation. It indicates that Module:Currency doesn't know where to place the currency's symbol in relation to its value.{{currency}} – definition missing page – an internal error that should only occur when an editor is mucking about in Module:Currency/Presentation. It indicates that Module:Currency doesn't have a page that it can use to link the currency's symbol or name.
TemplateData
{{TemplateData header}}
{
"description": "Use this template to provide a linked currency symbol and the amount of cash.",
"format": "inline",
"params": {
"1": {
"aliases": [
"amount",
"Amount"
],
"label": "Amount",
"description": "The value in the given currency",
"required": true,
"type": "line"
},
"2": {
"aliases": [
"code",
"type",
"Type"
],
"label": "Currency",
"description": "The currency represented. Should be a valid ISO 4217 code or one of the special codes listed on the template’s page",
"example": "USD",
"default": "USD",
"suggested": true,
"type": "line"
},
"first": {
"label": "Long form",
"description": "When set to any value, produces a long-form currency name. This should be used for the first mention of a currency within the article",
"type": "line"
},
"linked": {
"label": "Link currency",
"description": "Whether to link to the article on that currency. “no” suppresses the link, any other value displays it",
"example": "no",
"default": "yes",
"type": "line"
},
"fmt": {
"label": "Format",
"description": "Specifies how value digit-groups are separated: commas, gaps or none",
"example": "gaps",
"default": "commas",
"type": "line"
},
"passthrough": {
"label": "Passthrough",
"description": "If \"yes\", put the string in Amount directly after its symbol without turning it into a number.",
"example": "yes",
"default": "no",
"type": "line"
}
}
}
See also
- Wikipedia:Manual of Style (dates and numbers)#Currencies for important usage pattern instructions.
- {{tl|Format price}}, a template that handles rounding and "big number" formatting
- {{tl|Inflation}}, a template that adjusts historical costs to current (or other-year) equivalent value
- {{tlx|Infobox currency}}
}}