docs(API): 翻译完了 DecimalPipe 和 CurrencyPipe

This commit is contained in:
Zhicheng Wang 2018-09-04 10:12:28 +08:00
parent ec886a90ef
commit e8d4f26644
2 changed files with 113 additions and 5 deletions

View File

@ -46,8 +46,8 @@
[x] | common/NgTemplateOutlet | 0.42
[x] | common/Location | 0.41
[x] | platform-browser/BrowserModule | 0.40
[ ] | common/DecimalPipe | 0.40
[ ] | common/CurrencyPipe | 0.39
[x] | common/DecimalPipe | 0.40
[x] | common/CurrencyPipe | 0.39
[ ] | router/RouterLinkActive | 0.38
[ ] | core/TemplateRef | 0.38
[ ] | forms/FormBuilder | 0.37

View File

@ -20,12 +20,19 @@ import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
* separator, decimal-point character, and other locale-specific
* configurations.
*
*
*
*
* If no parameters are specified, the function rounds off to the nearest value using this
* [rounding method](https://en.wikibooks.org/wiki/Arithmetic/Rounding).
* The behavior differs from that of the JavaScript ```Math.round()``` function.
* In the following case for example, the pipe rounds down where
* ```Math.round()``` rounds up:
*
* 使[](https://en.wikibooks.org/wiki/Arithmetic/Rounding)。
* JavaScript ```Math.round()```
* ```Math.round()```
*
* ```html
* -2.5 | number:'1.0-0'
* > -3
@ -40,8 +47,12 @@ import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
* into text strings, according to various format specifications,
* where the caller's default locale is `en-US`.
*
* 使 `en-US`
*
* ### Example
*
* ###
*
* <code-example path="common/pipes/ts/number_pipe.ts" region='NumberPipe'></code-example>
*
*
@ -52,18 +63,38 @@ export class DecimalPipe implements PipeTransform {
/**
* @param value The number to be formatted.
*
*
*
* @param digitsInfo Decimal representation options, specified by a string
* in the following format:<br>
* <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
*
* <br>
* <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>
*
* - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
* Default is `1`.
*
* `minIntegerDigits` `1`
*
* - `minFractionDigits`: The minimum number of digits after the decimal point.
* Default is `0`.
*
* `minFractionDigits` `0`
*
* - `maxFractionDigits`: The maximum number of digits after the decimal point.
* Default is `3`.
*
* `maxFractionDigits` `3`
*
* @param locale A locale code for the locale format rules to use.
* When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
* See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
*
* 使
* 使 `LOCALE_ID` `en-US`
* [locale](guide/i18n#setting-up-the-locale-of-your-app)
*/
transform(value: any, digitsInfo?: string, locale?: string): string|null {
if (isEmpty(value)) return null;
@ -88,6 +119,9 @@ export class DecimalPipe implements PipeTransform {
* separator, decimal-point character, and other locale-specific
* configurations.
*
*
*
*
* @see `formatPercent()`
*
* @usageNotes
@ -95,6 +129,9 @@ export class DecimalPipe implements PipeTransform {
* into text strings, according to various format specifications,
* where the caller's default locale is `en-US`.
*
*
* 使 `en-US`
*
* <code-example path="common/pipes/ts/percent_pipe.ts" region='PercentPipe'></code-example>
*
*
@ -106,18 +143,39 @@ export class PercentPipe implements PipeTransform {
/**
*
* @param value The number to be formatted as a percentage.
*
*
*
* @param digitsInfo Decimal representation options, specified by a string
* in the following format:<br>
* <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
*
* <br>
* <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>
*
*
* - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
* Default is `1`.
*
* `minIntegerDigits` `1`
*
* - `minFractionDigits`: The minimum number of digits after the decimal point.
* Default is `0`.
*
* `minFractionDigits` `0`
*
* - `maxFractionDigits`: The maximum number of digits after the decimal point.
* Default is `3`.
*
* `maxFractionDigits` `3`
*
* @param locale A locale code for the locale format rules to use.
* When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
* See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
*
* 使
* 使 `LOCALE_ID` `en-US`
* [locale](guide/i18n#setting-up-the-locale-of-your-app)
*/
transform(value: any, digitsInfo?: string, locale?: string): string|null {
if (isEmpty(value)) return null;
@ -141,6 +199,9 @@ export class PercentPipe implements PipeTransform {
* that determine group sizing and separator, decimal-point character,
* and other locale-specific configurations.
*
*
*
*
* @see `getCurrencySymbol()`
* @see `formatCurrency()`
*
@ -149,6 +210,9 @@ export class PercentPipe implements PipeTransform {
* into text strings, according to various format specifications,
* where the caller's default locale is `en-US`.
*
*
* 使 `en-US`
*
* <code-example path="common/pipes/ts/currency_pipe.ts" region='CurrencyPipe'></code-example>
*
*
@ -160,33 +224,75 @@ export class CurrencyPipe implements PipeTransform {
/**
*
* @param value The number to be formatted as currency.
*
*
*
* @param currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code,
* such as `USD` for the US dollar and `EUR` for the euro.
*
* [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 中的货币代码,比如 `USD` 表示美元,`EUR` 表示欧元。
*
* @param display The format for the currency indicator. One of the following:
*
*
*
* - `code`: Show the code (such as `USD`).
*
* `code`: `USD`
*
* - `symbol`(default): Show the symbol (such as `$`).
*
* `symbol`(default): `$`
*
* - `symbol-narrow`: Use the narrow symbol for locales that have two symbols for their
* currency.
* For example, the Canadian dollar CAD has the symbol `CA$` and the symbol-narrow `$`. If the
* locale has no narrow symbol, uses the standard symbol for the locale.
*
* `symbol-narrow`: 使
* `CA$` `$`使
*
* - String: Use the given string value instead of a code or a symbol.
*
* String: 使
*
* - Boolean (marked deprecated in v5): `true` for symbol and false for `code`.
*
* Boolean v5 `true` `false`
*
* @param digitsInfo Decimal representation options, specified by a string
* in the following format:<br>
* <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
*
* <br>
* <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>
*
*
* - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
* Default is `1`.
*
* `minIntegerDigits` `1`
*
* - `minFractionDigits`: The minimum number of digits after the decimal point.
* Default is `0`.
*
* `minFractionDigits` `0`
*
* - `maxFractionDigits`: The maximum number of digits after the decimal point.
* Default is `3`.
* If not provided, the number will be formatted with the proper amount of digits,
* depending on what the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) specifies.
* For example, the Canadian dollar has 2 digits, whereas the Chilean peso has none.
*
* `maxFractionDigits` `3`
*
* @param locale A locale code for the locale format rules to use.
* When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
* See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
*
* 使
* 使 `LOCALE_ID` `en-US`
* [locale](guide/i18n#setting-up-the-locale-of-your-app)
*/
transform(
value: any, currencyCode?: string,
@ -228,6 +334,8 @@ function isEmpty(value: any): boolean {
/**
* Transforms a string into a number (if needed).
*
*
*/
function strToNumber(value: number | string): number {
// Convert strings to numbers