Kendo UI Internationalization
Перейти к файлу
Tsvetomir Tsonev 1f9efaaf86
fix(currency): symbol fallback
Fixes the semantic release commit message for
d2286da466
2024-01-08 16:16:58 +02:00
.github/workflows chore: read secrets from Akeyeless 2023-05-18 18:17:05 +03:00
docs docs: update CLDR data docs 2022-07-07 14:00:58 +03:00
examples fix: add currencyData for default currency to pre-built locales 2019-07-23 17:03:01 +03:00
locale-tests chore: refactor test locales 2022-07-07 16:37:08 +03:00
src Symbol fallback (#129) 2024-01-08 09:24:19 +02:00
test Symbol fallback (#129) 2024-01-08 09:24:19 +02:00
.eslintrc.js chore: set up eslint for jest 2022-07-06 11:34:34 +03:00
.gitignore chore: ignore dist and tmp folder 2016-07-04 14:55:22 +03:00
CODEOWNERS chore: update Codeowners (#109) 2021-05-05 14:00:48 +03:00
CONTRIBUTING.md docs: update link to CLA 2017-05-29 11:25:34 +03:00
LICENSE.md fix: update license 2022-06-06 14:50:41 +03:00
NOTICE.txt chore: update year to 2021 (#107) 2021-03-10 07:13:43 +02:00
README.md docs: update package link in readme 2023-01-03 13:24:45 +02:00
build-locales.js feat: add milliseconds to calendar units 2022-07-06 11:34:34 +03:00
gulpfile.js refactor: migrate to unicode-org/cldr-json 2022-07-06 11:34:34 +03:00
jest.config.json chore: migrate tests to jest 2022-07-06 11:34:34 +03:00
package.json test: fix test data 2022-07-07 16:37:08 +03:00

README.md

Commitizen friendly Build Status npm version

Kendo UI Internationalization

This repository contains the source code and documentation of the Kendo UI Internationalization package.

It includes methods for parsing and formatting dates and numbers by using Unicode Common Locale Data Repository (CLDR) data. These methods are split into the following modules:

Basic Usage

CLDR Data

To use the Unicode® CLDR data, you need to install the following subset of cldr-json packages by running the following command:

npm install --save cldr-core cldr-dates-full cldr-numbers-full

To apply the methods for different locales, load the likelySubtags and the locale data by using the load method.

Additionally, the library requires you to load:

  • The supplemental currencyData for the default currency formatting.
  • The weekData for the day of week formatting.
import { load } from '@progress/kendo-intl';

load(
    require('cldr-core/supplemental/likelySubtags.json'),
    require('cldr-core/supplemental/currencyData.json'),
    require('cldr-core/supplemental/weekData.json'),

    require('cldr-numbers-full/main/bg/numbers.json'),
    require('cldr-numbers-full/main/bg/currencies.json'),

    require('cldr-dates-full/main/bg/dateFields.json'),
    require('cldr-dates-full/main/bg/ca-gregorian.json'),
    require('cldr-dates-full/main/bg/timeZoneNames.json')
);

For more examples and available configuration options, refer to the article on CLDR Data.

Date Parsing

Date parsing converts a string into a Date object by using the specific settings of the locale.

import { parseDate } from '@progress/kendo-intl';

parseDate("11/6/2000", ["G", "d"]); // Mon Nov 06 2000
parseDate("Montag, 6.11.2000", "EEEE, d.MM.y", "de"); // Mon Nov 06 2000
parseDate("2000-11-06T10:30Z"); // Mon Nov 06 2000 12:30

For more examples and available configuration options, refer to the article on date parsing.

Date Formatting

Date formatting converts a Date object into a human-readable string by using the specific settings of the locale.

import { formatDate } from '@progress/kendo-intl';

formatDate(new Date(2000, 10, 6), "d"); // 11/6/2000
formatDate(new Date(2000, 10, 6), "yMd", "de"); // 6.11.2000
formatDate(new Date(2000, 10, 6), "EEEE, d.MM.y", "bg"); // понеделник, 6.11.2000

For more examples and available configuration options, refer to the article on date formatting.

Number Parsing

Number parsing converts a string into a Number object by using the specific settings of the locale.

import { parseNumber } from '@progress/kendo-intl';

parseNumber("12.22"); // 12.22
parseNumber("1.212,22 €", "de"); // 1212.22
parseNumber("10.22 %"); // 0.1022
parseNumber("1,0000123e+4", "bg"); // 10000.123

For more examples and available configuration options, refer to the article on number parsing.

Number Formatting

Number formatting converts a Number object into a human-readable string using the specific settings of the locale.

import { formatNumber } from '@progress/kendo-intl';

formatNumber(1234.567, "n2"); // 1,234.57

formatNumber(1234.567, "c", "de"); // 1.234,57 €

formatNumber(1234.567, {
   style: "currency",
   currency: "USD",
   currencyDisplay: "displayName"
}, "bg"); // 1 234,57 щатски долара

formatNumber(2345678, "##,#.00"); // 2,345,678.00

For more examples and available configuration options, refer to the article on number formatting.

General Formatting

General formatting provides methods for independent placeholder and type formatting by using the specific settings of the locale.

import { format, toString } from '@progress/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.

Installation

  1. The Internationalization library is published as a scoped NPM package in the NPMJS Telerik account.

  2. Download and install the module:

    npm install --save '@progress/kendo-intl';
    
  3. Once installed, import the Internationalization in your application root module:

    // ES2015 module syntax
    import { formatDate, parseDate } from '@progress/kendo-intl';
    //or
    import { formatNumber, parseNumber } from '@progress/kendo-intl';
    
    // CommonJS format
    var numbers = require('@progress/kendo-intl/number').numbers;
    //or
    var dates = require('@progress/kendo-intl/dates').dates;