Mall:FormateraValuta

Från Wikipedia

[visa] [redigera] [rensa sidcachen]

Dokumentation


Användning[redigera wikitext]

Using unnamed parameters:

{{currency|[value?]|[code?]|first=|linked=|fmt=|passthrough=}}

Using named parameters:

{{currency|amount=[value?]|code=[code?]|first=|linked=|passthrough=}}

where:

[value?] is a number with or without comma separators; may be followed by an optional quantifier: 'thousand', 'million', 'M', 'billion', 'B', or 'trillion'
[code?] is an ISO 4217 currency code or one of the supported non-standard codes listed below
|first= when set to any value produces a long-form currency name
|linked= when set to no disables wikilinks on the rendered currency symbol or long-form currency name
|fmt= specifies how [value?] digit-groups are separated:
commas (default) separates [value?] digit-groups with commas; this is the default, same as when |fmt= is empty or omitted
gaps separates [value?] digit-groups with narrow gaps
none renders [value?] without digit grouping

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:

{{Valuta|amount=1000|GBP}}
{{currency}} – invalid amount (help)
|passthrough= specifies whether or not the template should attempt to parse the number according to |fmt= or just put whatever string is provided in |amount= directly after the currency sign. Should have value of either |passthrough=yes or |passthrough=no

When using parameter names, |amount= and |code= are preferred. The template will also accept |Amount= and |type= and |Type=, though.

Stödda icke-standard valutakoder[redigera wikitext]

Codes that can be translated to ISO 4217 currencies[redigera wikitext]

These non-standard codes are aliases of standard ISO 4217 codes.

  • EGE
  • EU
  • EURO
  • FRW
  • KSH
  • NEP
  • POUND
  • POUND STERLING
  • RMB
  • TSH
  • UK
  • UNITED STATES
  • US
  • U.S.
  • USA
  • USH

Andra icke-standard koder[redigera wikitext]

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

Exampel[redigera wikitext]

Currencies other than the United States dollar can be rendered by using the appropriate ISO 4217 currency code

Some of the more well known currencies also provide the ability to use common abbreviations or full names.

  • {{FormateraValuta|1000|US}} gives: US$1 000
  • {{FormateraValuta|1000|United States}} gives: US$1 000
  • {{FormateraValuta|1,000|JPY}} gives: ¥1 000

Parameter names can also be used, if preferred:

  • {{FormateraValuta|amount=1000|code=US}} gives: US$1 000
  • {{FormateraValuta|1000|code=euro}} gives: 1 000

Negative amount:

  • {{FormateraValuta|amount=-1000|code=US}} gives: US$−1 000

Text quantifiers:

  • {{FormateraValuta|1000 million|code=euro}} gives: {{currency}} – invalid amount (help)
  • {{FormateraValuta|1000M|code=euro}} gives: {{currency}} – invalid amount (help)

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.

  • {{FormateraValuta|1000|cve|first=yes}} gives: 000$00
  • {{FormateraValuta|1000|cve}} gives: 000$00

Because the symbol for the currencies DKK, NOK, and SEK may be ambiguous, these may be represented in two ways:

  • For DKK:
    {{FormateraValuta|1000|dkk}} gives: kr. 1 000
    {{FormateraValuta|1000|dkk2}} gives: DKK 1 000
  • For NOK:
    {{FormateraValuta|1000|NOK}} gives: kr 1 000
    {{FormateraValuta|1000|NOK2}} gives: NOK 1 000
  • For SEK:
    {{FormateraValuta|1000|SEK}} gives: 1 000 kr
    {{FormateraValuta|1000|SEK2}} gives: SEK 1 000

Similarly, some currencies use different symbols for single and plural amounts:

  • {{FormateraValuta|1|LSL}} gives: L1
    {{FormateraValuta|1000|LSL2}} gives: M1 000
    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:

  • |fmt=commas
    {{FormateraValuta|1000 miljon|code=euro|fmt=commas}} gives: {{currency}} – invalid format (help)
  • |fmt=gaps
    {{FormateraValuta|1000 miljon|code=euro|fmt=gaps}} gives: {{currency}} – invalid format (help)
  • |fmt=none
    {{FormateraValuta|1000 miljon|code=euro|fmt=none}} gives: {{currency}} – invalid format (help)

Passthrough:

  • |passthrough=yes
    {{FormateraValuta|6 million|PHP|passthrough=yes}} gives: {{currency}} – invalid amount (help)
    {{FormateraValuta|6 trillion|PHP|passthrough=yes}} gives: {{currency}} – invalid amount (help)
    {{FormateraValuta|6 tn|PHP|passthrough=yes}} gives: {{currency}} – invalid amount (help)
  • |passthrough=no
    {{FormateraValuta|6 million|PHP|passthrough=no}} gives: {{currency}} – invalid amount (help)
    {{FormateraValuta|6 trillion|PHP|passthrough=no}} gives: {{currency}} – invalid amount (help)
    {{FormateraValuta|6 tn|PHP|passthrough=no}} gives: {{currency}} – invalid amount (help) (error expected, as template doesn't know how to parse 6 tn to 6,000,000,000,000)
  • Use sparingly! Usually you want |fmt= instead. |passthrough= should only be used in ways compatible with MOS:CURRENCY.

Felmeddelanden[redigera wikitext]

{{FormateraValuta}} can produce several error message. These are:

  • {{currency}} – invalid code – the value in the second unnamed parameter or assigned to |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 |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 (|amount= and |code=) or both unnamed.
  • {{currency}} – definition missing position – an internal error that should only occur when an editor is mucking about in Module:FormateraValuta/Presentation. It indicates that Module:FormateraValuta 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:FormateraValuta/Presentation. It indicates that Module:FormateraValuta doesn't have a page that it can use to link the currency's symbol or name.

Mall data[redigera wikitext]

Importerad mall från engelska Wikipedia. Formaterar valutamängder enligt ISO-kod och nationella valutasymboler. Kan hantera "tusen" till "triljard". Detta läggs helt enkelt till i fältet för mängd.

Mallparametrar[Redigera TemplateData]

Denna mall föredrar inline-formatering av parametrar.

ParameterBeskrivningTypStatus
Mängdmängd antal pris

Mängden valuta som ska visas

Föreslagna värden
10 100 10 tusen 100 tusen 1 miljon 1 miljard 1 triljon 9248 tusen
Standard
Standarden är en tom sträng: "".
Exempel
{{100 tusen| SEK}} ger 100,000 kr.
Autovärde
Autovärdet är en tom sträng: "".
Strängobligatorisk
Valuta-kodkod ISO ISO-kod Valuta Valuta-kod

Definierar enligt vilken valuta mängden pengar ska formateras.

Föreslagna värden
SEK SEK2 USD GBP EUR XXX
Standard
Standard är "XXX", vilket resulterar i tecknet för generisk valuta.
Exempel
SEK, SEK2, UVU, USD, GBP, EUR
Autovärde
XXX
Strängföreslagen
formatformat separering

Bestämmer hur valuta-värdet ska separeras. Klarar komma, mellanrum eller inget.

Föreslagna värden
ingen mellanrum komma
Standard
komma
Exempel
ingen, mellanrum eller komma.
Autovärde
komma
Strängvalfri
långformlångform first long utdragen extra lång

Om långform är satt till "ja" formateras valutavärdet enligt långformsformat på valutanamnet.

Föreslagna värden
ja oifylld allt-utom-ja
Standard
Standard är strängen "", dvs. inget.
Exempel
{{10 | SEK| komma | "Ja" }} ger 10 Svenska kronor
Autovärde
Autovärdet är inget dvs. "".
Strängvalfri
länkadlänkad länk url markera navigation

Om satt till "ja", skapas en länk till valutaartikeln som definierats i parameter 2 dvs. "kod". Om parameter 2 är satt till "nej" skapas inte en länk till valutaartikeln".

Föreslagna värden
ja nej
Standard
ja
Exempel
"ja", "nej"
Autovärde
ja
Strängvalfri
formateraformatera använd_formatering passthrough

Definierar om vi formaterar enligt parameter #3 "format". Om satt till "nej" sker ingen formatering enligt "format" och om satt till "ja" sker formateringen enligt "format".

Föreslagna värden
ja nej
Standard
ja
Exempel
"ja", "nej"
Autovärde
ja
Strängvalfri

Omdirigeringar[redigera wikitext]

Se även[redigera wikitext]

  • {{Format price}}, a template that handles rounding and "big number" formatting
  • {{Inflation}}, a template that adjusts historical costs to current (or other-year) equivalent value
  • {{Infobox currency}}

{{sandbox other||