Skip to content

I18n

i18n : object

Functions to help support multiple currencies and countries.

Kind: global namespace

i18n.country() ⇒ string

Get the 2-character ISO country code that PostalPoint is running in.

Kind: static method of i18n
Returns: string - "US", "CA", etc.

i18n.currency() ⇒ string

Get the 3-character currency code in use.

Kind: static method of i18n
Returns: string - "usd", "cad", etc.

i18n.symbol() ⇒ string

Get the currency symbol.

Kind: static method of i18n
Returns: string - "$", "€", "₤", etc

i18n.decimals() ⇒ number

Get the number of decimal places for the currency: for example, USD has 2 ($x.00), KRW has 0 (x), UYW has 4 (x.0000).

Kind: static method of i18n
Returns: number - 0, 2, 3, or 4

i18n.convertCurrency(amount, fromCurrency, [toCurrency]) ⇒ Promise.<number>

Convert an amount of money to a different currency. Conversion rate is retrieved from the internet and cached for 4 hours.

Kind: static method of i18n

Param Type Default Description
amount number Amount of money in the "wrong" currency
fromCurrency string The currency code for the "wrong" currency that needs conversion
[toCurrency] string "getCurrencyCode()" The "correct" currency we want the amount to be in.

i18n.moneyToFixed(amount) ⇒ string

Returns the amount as a string formatted with the correct number of decimal places for the currency in use.

Kind: static method of i18n
Returns: string - "1.23", "1.2345", etc

Param Type
amount number

i18n.moneyString(amount) ⇒ string

Returns the amount as a string, with the correct decimal places, and the local currency symbol.

Kind: static method of i18n
Returns: string - "$1.23", etc

Param Type
amount number