goog.i18n.currency
Functions
addTier2Support() → void
void
This function will add tier2 currency support. Be default, only tier1 (most popular currencies) are supported. If an application really needs to support some of the rarely used currencies, it should call this function before any other functions in this namespace.
adjustPrecision( pattern, currencyCode ) → string
string
Modify currency pattern string by adjusting precision for given currency. Standard currency pattern will have 2 digit after decimal point. Examples: $#,##0.00 -> $#,##0 (precision == 0) $#,##0.00 -> $#,##0.0 (precision == 1) $#,##0.00 -> $#,##0.000 (precision == 3)
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
getGlobalCurrencyPattern( currencyCode ) → string
string
Deprecated. Global currency pattern always uses ISO-4217 currency code as prefix. Local currency sign is added if it is different from currency code. Each currency is unique in this form. The negative side is that ISO code looks weird in some countries as people normally do not use it. Local currency sign alleviates the problem, but also makes it a little verbose.
warning Deprecated | Format numbers using |
---|
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getGlobalCurrencySign( currencyCode ) → string
string
getGlobalCurrencySignWithFallback( currencyCode ) → string
string
Return global currency sign string for those applications that want to handle currency sign themselves.
This function does not throw an exception if there is no data for the currency. Instead, it falls back to the ISO code.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getLocalCurrencyPattern( currencyCode ) → string
string
Deprecated. Local currency pattern is the most frequently used pattern in currency's native region. It does not care about how it is distinguished from other currencies.
warning Deprecated | Format numbers using |
---|
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getLocalCurrencySign( currencyCode ) → string
string
getLocalCurrencySignWithFallback( currencyCode ) → string
string
Returns local currency sign string for those applications that need to handle currency sign separately.
This function does not throw an exception if there is no data for the currency. Instead, it falls back to the ISO code.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getPortableCurrencyPattern( currencyCode ) → string
string
Deprecated. Portable currency pattern is a compromise between local and global. It is not a mere blend or mid-way between the two. Currency sign is chosen so that it looks familiar to native users. It also has enough information to distinguish itself from other popular currencies in its native region. In this pattern, currency sign symbols that has availability problem in popular fonts are also avoided.
warning Deprecated | Format numbers using |
---|
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getPortableCurrencySign( currencyCode ) → string
string
getPortableCurrencySignWithFallback( currencyCode ) → string
string
Return portable currency sign string for those applications that need to handle currency sign themselves.
This function does not throw an exception if there is no data for the currency. Instead, it falls back to the ISO code.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
isAvailable( currencyCode ) → boolean
boolean
Tests if currency is available.
Note: If the currency is not available it might be in the tier2 currency set:
goog.i18n.currency.CurrencyInfoTier2
. If that is the case call
goog.i18n.currency.addTier2Support
before calling any other function
in this namespace.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
isPrefixSignPosition( currencyCode ) → boolean
boolean
This function returns the default currency sign's position. Some applications may want to handle currency sign and currency amount separately. This function can be used in such situations to correctly position the currency sign relative to the amount.
Use goog.i18n.NumberFormat#isCurrencyCodeBeforeValue
for a locale
aware version of this API (recommended). isPrefixSignPosition() returns the
default currency sign's position in the currency's default locale (e.g. 'en'
for 'USD'), but most commonly the position is needed for the locale in which
the number is going to be displayed. For example, in 'fr' 10.10 USD would be
displayed as '10,10 $'.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
isValid( currencyCode ) → boolean
boolean
Properties
Tier 1 currency information.
Format of the info array:
0. {number} the sum of "decimal precision", the "space" bit, and the
"currency sign last" bit.
1. {string} The global currency sign. See getGlobalCurrencySign
.
2. {string} The portable currency sign. See getPortableCurrencySign
.
"Decimal precision" is an integer [0..7]; the count of digits to display past the decimal point.
"Space" bit mask = 32; whether a space should be inserted between the currency sign and number.
"Currency sign last" bit mask = 16; whether the currency sign should be positioned after the number.
Examples for info[0]: 0: no precision (0), currency sign first (0), no space (0) 2: two decimals precision (2), currency sign first (0), no space (0) 18: two decimals precision (2), currency sign last (16), no space (0) 50: two decimals precision (2), currency sign last (16), space (32)
It's not recommended to read this data directly. Format numbers using
goog.i18n.NumberFormat
with
goog.i18n.NumberFormat.Format.CURRENCY
instead.
Tier 2 currency information.
It's not recommended to read this data directly. Format numbers using
goog.i18n.NumberFormat
with
goog.i18n.NumberFormat.Format.CURRENCY
instead.