currencies
- Description:
- Does string formatting and translation given a locale.
Because method names are going to be used in templates, we keep them short, but descriptive.
Method names are nouns describing what they return (rather than verbs), e.g..lower()and.upper()
Methods ususally take one argument, and an additional options dictionary. See options for full documentation of available options.
Some methods can be chained, for readability:month().upper()is equivalent toupper(month()).
- Does string formatting and translation given a locale.
Methods
(static) currency(number, code, optsopt) → {string}
- Description:
- Returns a currency string, with full currency name. The number of available number formatting options is much smaller, as we follow the deafult formatting patterns for currencies. If you need more control, use the currencyName and number methods together with your own formatting patterns.
Example
sv
// returns '23,50 euro'
currency(23.5, "EUR")
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
number |
number | A number | ||||||||||
code |
string | A currency code | ||||||||||
opts |
object |
<optional> |
Options
Properties
|
|||||||||
opt.zeroSign |
number |
<optional> |
0
|
What sign should the number 0 have? 1, -1 or 0 | ||||||||
opt.decimalDigits |
number |
<optional> |
1
|
Number of decimal digits | ||||||||
opt.numberSystem |
string |
<optional> |
Numbering system, if non-default. Will not work with complex numbering systems, like Amharic. | |||||||||
opt.forceDecimalDigits |
boolean |
<optional> |
false
|
Keep trailing zeros | ||||||||
opt.precision |
number |
<optional> |
A indicative number to round to, e.g. 1_000 |
|||||||||
opt.significantDigits |
number |
<optional> |
A number of significant digits to show, e.g. 3 |
Returns:
A textual representation
- Type
- string
(static) currencyName(code) → {string}
- Description:
- Return the local, fulltext name of a currency
The method name
currencyis reserved for future use as a currency fomatter.
- Return the local, fulltext name of a currency
The method name
Example
sv
// returns 'euro'
currencyName("EUR")
Parameters:
| Name | Type | Description |
|---|---|---|
code |
string | A currency code |
Returns:
A textual representation
- Type
- string
(static) currencyShort(number, code, optsopt) → {string}
- Description:
- Returns a currency string, with currency symbol. The number of available number formatting options is much smaller, as we follow the deafult formatting patterns for currencies. If you need more control, use the currencyName and number methods together with your own formatting patterns.
Example
sv
// returns '23,50 €'
currencyShort(23.5, "EUR")
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
number |
number | A number | |||||||||
code |
string | A currency code | |||||||||
opts |
object |
<optional> |
Options
Properties
|
Returns:
A textual representation
- Type
- string
(static) currencySymbol(code) → {string}
- Description:
- Return the locally recommended symbol of a currency, falling back to the full name
Note that the method name
currencyis reserved for future use as a currency fomatter.
- Return the locally recommended symbol of a currency, falling back to the full name
Note that the method name
Example
sv
// returns '€'
currencySymbol("EUR")
Parameters:
| Name | Type | Description |
|---|---|---|
code |
string | A currency code |
Returns:
A textual representation
- Type
- string