MCPcopy Create free account
hub / github.com/angular/angular / getCurrencySymbol

Function getCurrencySymbol

packages/common/src/i18n/locale_data_api.ts:797–806  ·  view source on GitHub ↗
(code: string, format: 'wide' | 'narrow', locale = 'en')

Source from the content-addressed store, hash-verified

795 * Note: `US$` is a currency symbol for the `en-ca` locale but not the `en-us` locale.
796 */
797export function getCurrencySymbol(code: string, format: 'wide' | 'narrow', locale = 'en'): string {
798 const currency = getLocaleCurrencies(locale)[code] || CURRENCIES_EN[code] || [];
799 const symbolNarrow = currency[ɵCurrencyIndex.SymbolNarrow];
800
801 if (format === 'narrow' && typeof symbolNarrow === 'string') {
802 return symbolNarrow;
803 }
804
805 return currency[ɵCurrencyIndex.Symbol] || code;
806}
807
808// Most currencies have cents, that's why the default is 2
809const DEFAULT_NB_OF_CURRENCY_DIGITS = 2;

Callers 2

transformMethod · 0.90

Calls 1

getLocaleCurrenciesFunction · 0.85

Tested by

no test coverage detected