currencies

Namespace

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 to upper(month()).

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
Name Type Attributes Description
numberSystem string <optional>
What number system should we use? Defaults to the standard for decimal numbers in the current locale, e.g. 'latn' or 'arab'.
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 currency is reserved for future use as a currency fomatter.
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
Name Type Attributes Description
numberSystem string <optional>
What number system should we use? Defaults to the standard for decimal numbers in the current locale, e.g. 'latn' or 'arab'.
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 currency is reserved for future use as a currency fomatter.
Example

sv

// returns '€'
currencySymbol("EUR")
Parameters:
Name Type Description
code string A currency code
Returns:
A textual representation
Type
string