feat: i18n - include currency code in locale data (#32584)

PR Close #32584
This commit is contained in:
Pete Bacon Darwin
2019-12-14 10:39:41 +00:00
committed by atscott
parent ca1bc7e80b
commit ed2f5e0efa
4 changed files with 49 additions and 18 deletions

View File

@ -63,6 +63,21 @@ export function findLocaleData(locale: string): any {
throw new Error(`Missing locale data for the locale "${locale}".`);
}
/**
* Retrieves the default currency code for the given locale.
*
* The default is defined as the first currency which is still in use.
*
* @param locale The code of the locale whose currency code we want.
* @returns The code of the default currency for the given locale.
*
* @publicApi
*/
export function getLocaleCurrencyCode(locale: string): string|null {
const data = findLocaleData(locale);
return data[LocaleDataIndex.CurrencyCode] || null;
}
/**
* Retrieves the plural function used by ICU expressions to determine the plural case to use
* for a given locale.
@ -116,6 +131,7 @@ export enum LocaleDataIndex {
DateTimeFormat,
NumberSymbols,
NumberFormats,
CurrencyCode,
CurrencySymbol,
CurrencyName,
Currencies,

View File

@ -44,6 +44,7 @@ export default [
['{1}, {0}', u, '{1} \'at\' {0}', u],
['.', ',', ';', '%', '+', '-', 'E', '×', '‰', '∞', 'NaN', ':'],
['#,##0.###', '#,##0%', '¤#,##0.00', '#E0'],
'USD',
'$',
'US Dollar',
{},