docs: add deprecation info about default currency code (#34771)

In v10 the default currency code will be taken from the
current locale, rather than simply defaulting to `USD`.

PR Close #34771
This commit is contained in:
Pete Bacon Darwin
2020-01-10 12:41:05 +00:00
committed by atscott
parent a7cd7d4df6
commit a8c789d98d
4 changed files with 50 additions and 5 deletions

View File

@ -123,9 +123,7 @@ export class PercentPipe implements PipeTransform {
*/
transform(value: any, digitsInfo?: string, locale?: string): string|null {
if (isEmpty(value)) return null;
locale = locale || this._locale;
try {
const num = strToNumber(value);
return formatPercent(num, locale, digitsInfo);
@ -143,6 +141,26 @@ export class PercentPipe implements PipeTransform {
* that determine group sizing and separator, decimal-point character,
* and other locale-specific configurations.
*
* {@a currency-code-deprecation}
* <div class="alert is-helpful">
*
* **Deprecation notice:**
*
* The default currency code is currently always `USD` but this is deprecated from v9.
*
* **In v11 the default currency code will be taken from the current locale identified by
* the `LOCAL_ID` token. See the [i18n guide](guide/i18n#setting-up-the-locale-of-your-app) for
* more information.**
*
* If you need the previous behavior then set it by creating a `DEFAULT_CURRENCY_CODE` provider in
* your application `NgModule`:
*
* ```ts
* {provide: DEFAULT_CURRENCY_CODE, useValue: 'USD'}
* ```
*
* </div>
*
* @see `getCurrencySymbol()`
* @see `formatCurrency()`
*

View File

@ -39,6 +39,23 @@ export const LOCALE_ID = new InjectionToken<string>('LocaleId');
*
* See the [i18n guide](guide/i18n#setting-up-locale) for more information.
*
* <div class="alert is-helpful">
*
* **Deprecation notice:**
*
* The default currency code is currently always `USD` but this is deprecated from v9.
*
* **In v10 the default currency code will be taken from the current locale.**
*
* If you need the previous behavior then set it by creating a `DEFAULT_CURRENCY_CODE` provider in
* your application `NgModule`:
*
* ```ts
* {provide: DEFAULT_CURRENCY_CODE, useValue: 'USD'}
* ```
*
* </div>
*
* @usageNotes
* ### Example
*