docs: document format and toString methods

This commit is contained in:
Daniel Karadachki 2017-01-05 15:57:16 +02:00
Родитель eac81d17b9
Коммит fffefd78ef
6 изменённых файлов: 119 добавлений и 2 удалений

Просмотреть файл

@ -77,7 +77,7 @@ import { parseNumber } from '@telerik/kendo-intl';
parseNumber("12.22"); // 12.22
parseNumber("1.212,22 €", "de"); // 1212.22
parseNumber("10.22 %"); // 0.1022
parseNumber("10.22 %"); // 0.1022
parseNumber("1,0000123e+4", "bg"); // 10000.123
```
@ -105,6 +105,22 @@ formatNumber(2345678, "##,#.00"); // 2,345,678.00
For more examples and available configuration options, refer to the article on [number formatting](https://github.com/telerik/kendo-intl/blob/master/docs/num-formatting/index.md).
### General Formatting
Provides methods for placeholder and type independent formatting using the locale specific settings.
```js
import { format, toString } from '@telerik/kendo-intl';
format('Date: {0:d} - Price: {1:c}', [new Date(), 10.5], "en") // Date: 1/5/2017 - Price: $10.50
toString(10.5, "c", "bg"); // 10,50 лв.
toString(new Date(), "d"); // 1/5/2017
```
For more examples and available configuration options, refer to the article on [general formatting](https://github.com/telerik/kendo-intl/blob/master/docs/general-formatting/index.md).
## Installation
The Internationalization library is published as a [scoped NPM package](https://docs.npmjs.com/misc/scope) in the [NPMJS Telerik account](https://www.npmjs.com/~telerik).

Просмотреть файл

@ -3,7 +3,7 @@ title: Errors
page_title: Errors | Kendo UI Internationalization Package
description: "List of possible exceptions that the package could throw."
slug: errors_internalization_kendoui
position: 6
position: 7
---
# Errors list

Просмотреть файл

@ -0,0 +1,2 @@
title: General Formatting
position: 6

Просмотреть файл

@ -0,0 +1,61 @@
---
title: General Formatting API
page_title: General Formatting API | Kendo UI Internationalization
description: "Learn about the exported methods from the Kendo UI Internationalization General Formatting module."
slug: dateformatapi_internalization
position: 2
---
# General Formatting API
Provides information about the exported methods from the format module.
## Methods
#### format
Replaces the format string placeholders with the provided values based on the index.
## Parameters
#### formatString `String`
The format string.
#### values `Array`
The values that should be replaced in the format string
#### locale `String`
Optional locale id. If not specified 'en' will be used.
## Return Value
#### Returns `String`
The format string with replaced formatted values.
#### toString
Formats dates and numbers based on the specified format and locale
## Parameters
#### value `String|Date|Number`
The value to be formatted.
#### format `String|Object`
A string representing a predefined or custom date or number format, or a configuration object.
#### locale `String`
Optional locale id. If not specified 'en' will be used.
## Return Value
#### Returns `String`
The formatted value.

Просмотреть файл

@ -0,0 +1,36 @@
---
title: General Formatting
page_title: General Formatting | Kendo UI Internationalization
description: "Use the formatting capabilities of the format and toString methods when working with the Kendo UI Internationalization package."
slug: generalformatting_internalization
position: 1
---
# General Formatting
Provides methods for applying placeholder format and type independent value formatting using the locale specific settings.
## Placeholder formatting
The `format` method can be used to replace the format string placeholders(`{index}`) with the provided values based on the index.
A specific format can also be specified for `Date` and `Number` values by adding `:format` after the index.
import { format } from '@telerik/kendo-intl';
format('Date: {0:d} - Price: {1:c}', [new Date(), 10.5], "en"); // Date: 1/5/2017 - Price: $10.50
## Type independent formatting
The `toString` method can be used to format both `Date` and `Number` values using the locale specific settings. If a string is passed as value then it will be returned without modification.
import { toString } from '@telerik/kendo-intl';
toString(new Date(), "d", "en"); // 1/5/2017
toString(10.5, "c", "bg"); // 10,50 лв.
## Suggested Links
* [General Formatting API]({% slug generalformatapi_internalization %})
* [Date Formatting]({% slug dateformatting_internalization %})
* [Number Formatting]({% slug numbeformatting_internalization %})

Просмотреть файл

@ -18,6 +18,8 @@ The Date Parsing and Date Formatting modules provide methods for parsing and for
The Number Parsing and Number Formatting modules provide methods for parsing and formatting of numbers.
The General Formatting module provides methods for placeholder and type independent formatting.
## Suggested Links
* [Get Started with CLDR]({% slug cldrdata_overview_internalization %})