Skip to content

Commit b76b9e1

Browse files
danielkaradachkitsvetomir
authored andcommitted
docs: add documentation about using pre-generated locales
1 parent 4e42c19 commit b76b9e1

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed

docs/cldr/api.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,13 @@ The locale id.
150150
##### Returns `Object`
151151

152152
Holds the number symbols from the specified locale.
153+
154+
### setData
155+
156+
Sets pre-generated data. For information on how to generate the locales refer to the [Generated Data](https://github.com/telerik/kendo-intl/blob/master/docs/cldr/index.md#generated-data) documentation.
157+
158+
#### setData Parameters
159+
160+
##### data `Object`
161+
162+
The pre-generated data.

docs/cldr/index.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,44 @@ load(
6666
//the `cldr` object will consist the loaded data
6767
```
6868

69+
# Generated Data
70+
71+
The package provides a build method for generating the files with data required by the Kendo UI Internationalization library.
72+
The following example demonstrates generating the data for typescript projects.
73+
74+
```
75+
76+
const { buildLocales, toJSObject } = require('@telerik/kendo-intl/build-locales');
77+
const intl = require('@telerik/kendo-intl');
78+
79+
const localeTemplate = (data) => {
80+
return `export const data = ${ toJSObject(data) };`;
81+
};
82+
83+
buildLocales(intl, { contentTemplate: localeTemplate, extension: 'ts', destFolder: 'locales' });
84+
85+
```
86+
87+
The method will output four files in the destination locale folder:
88+
89+
* all - contains all required data.
90+
* numbers - contains the numbers data.
91+
* currencies - contains the currencies data.
92+
* calendar - contains the calendar data.
93+
94+
The generated data can be set via the [setData](https://github.com/telerik/kendo-intl/blob/master/docs/cldr/api.md#setdata) method.
95+
96+
```
97+
98+
import { setData } from '@telerik/kendo-intl';
99+
import { data } from './locales/bg/all';
100+
101+
setData(data);
102+
103+
```
104+
105+
> Note that the [cldr-data](https://www.npmjs.com/package/cldr-data) package must be installed in order to generate the locales.
106+
69107
## Suggested Links
70108

71109
* [API Reference of the CLDR Module]({% slug cldrapi_internalization %})

src/cldr.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ export function load(...data: any[]): void;
118118
*/
119119
export function numberSymbols(locale: string): any;
120120

121+
/**
122+
* Sets pre-generated data.
123+
*/
124+
export function setData(data: any): void;
125+
121126
/**
122127
* @hidden
123128
*/
@@ -156,8 +161,3 @@ export function localeInfo(locale: string): any;
156161
* @hidden
157162
*/
158163
export function territoryCurrencyCode(territory: string): any;
159-
160-
/**
161-
* @hidden
162-
*/
163-
export function setData(data: any): void;

0 commit comments

Comments
 (0)