-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API doc for pipes/i18n config #29289
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ const CURRENCY_CHAR = '¤'; | |
const PERCENT_CHAR = '%'; | ||
|
||
/** | ||
* Transforms a number to a locale string based on a style and a format | ||
* Transforms a number to a locale string based on a style and a format. | ||
*/ | ||
function formatNumberToLocaleString( | ||
value: number, pattern: ParsedNumberFormat, locale: string, groupSymbol: NumberSymbol, | ||
|
@@ -128,15 +128,21 @@ function formatNumberToLocaleString( | |
* | ||
* Formats a number as currency using locale rules. | ||
* | ||
* Use `currency` to format a number as currency. | ||
* @param value The number to format. | ||
* @param locale A locale code for the locale format rules to use. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a link to the locale section in the i18n guide here? |
||
* @param currency A string containing the currency symbol or its name, | ||
* such as "$" or "Canadian Dollar". Used in output string, but does not affect the operation | ||
* of the function. | ||
* @param currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) | ||
* currency code to use in the result string, such as `USD` for the US dollar and `EUR` for the euro. | ||
* @param digitInfo Decimal representation options, specified by a string in the following format: | ||
* `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details. | ||
* | ||
* Where: | ||
* - `value` is a number. | ||
* - `locale` is a `string` defining the locale to use. | ||
* - `currency` is the string that represents the currency, it can be its symbol or its name. | ||
* - `currencyCode` is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, such | ||
* as `USD` for the US dollar and `EUR` for the euro. | ||
* - `digitInfo` See {@link DecimalPipe} for more details. | ||
* @returns The formatted currency value. | ||
* | ||
* @see `formatNumber()` | ||
* @see `DecimalPipe` | ||
* @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) | ||
* | ||
* @publicApi | ||
*/ | ||
|
@@ -163,12 +169,18 @@ export function formatCurrency( | |
* | ||
* Formats a number as a percentage according to locale rules. | ||
* | ||
* Where: | ||
* - `value` is a number. | ||
* - `locale` is a `string` defining the locale to use. | ||
* - `digitInfo` See {@link DecimalPipe} for more details. | ||
* @param value The number to format. | ||
* @param locale A locale code for the locale format rules to use. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comments as above |
||
* @param digitInfo Decimal representation options, specified by a string in the following format: | ||
* `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details. | ||
* | ||
* @returns The formatted percentage value. | ||
* | ||
* @see `formatNumber()` | ||
* @see `DecimalPipe` | ||
* @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) | ||
* @publicApi | ||
* | ||
*/ | ||
export function formatPercent(value: number, locale: string, digitsInfo?: string): string { | ||
const format = getLocaleNumberFormat(locale, NumberFormatStyle.Percent); | ||
|
@@ -183,13 +195,16 @@ export function formatPercent(value: number, locale: string, digitsInfo?: string | |
* @ngModule CommonModule | ||
* @description | ||
* | ||
* Formats a number as text. Group sizing and separator and other locale-specific | ||
* configurations are based on the locale. | ||
* Formats a number as text, with group sizing, separator, and other | ||
* parameters based on the locale. | ||
* | ||
* @param value The number to format. | ||
* @param locale A locale code for the locale format rules to use. | ||
* @param digitInfo Decimal representation options, specified by a string in the following format: | ||
* `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details. | ||
* | ||
* Where: | ||
* - `value` is a number. | ||
* - `locale` is a `string` defining the locale to use. | ||
* - `digitInfo` See {@link DecimalPipe} for more details. | ||
* @returns The formatted text string. | ||
* @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n) | ||
* | ||
* @publicApi | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Time zone abbreviation doesn't seem to be supported: #20225