What is @progress/kendo-intl?
@progress/kendo-intl is a package that provides internationalization (i18n) and localization (l10n) functionalities. It includes features for formatting dates, numbers, and currencies, as well as parsing these formats. This package is particularly useful for applications that need to support multiple languages and regional settings.
What are @progress/kendo-intl's main functionalities?
Date Formatting
This feature allows you to format dates according to a specified pattern. The example formats a date object into a string with the format 'yyyy-MM-dd'.
const { formatDate } = require('@progress/kendo-intl');
const date = new Date(2023, 9, 5);
const formattedDate = formatDate(date, 'yyyy-MM-dd');
console.log(formattedDate); // Output: 2023-10-05
Number Formatting
This feature allows you to format numbers according to a specified pattern. The example formats a number to include two decimal places and uses commas as thousand separators.
const { formatNumber } = require('@progress/kendo-intl');
const number = 1234567.89;
const formattedNumber = formatNumber(number, 'n2');
console.log(formattedNumber); // Output: 1,234,567.89
Currency Formatting
This feature allows you to format numbers as currency. The example formats a number as US dollars.
const { formatCurrency } = require('@progress/kendo-intl');
const amount = 1234567.89;
const formattedCurrency = formatCurrency(amount, 'USD');
console.log(formattedCurrency); // Output: $1,234,567.89
Date Parsing
This feature allows you to parse date strings into Date objects according to a specified pattern. The example parses a date string into a Date object.
const { parseDate } = require('@progress/kendo-intl');
const dateString = '2023-10-05';
const parsedDate = parseDate(dateString, 'yyyy-MM-dd');
console.log(parsedDate); // Output: Thu Oct 05 2023 00:00:00 GMT+0000 (Coordinated Universal Time)
Number Parsing
This feature allows you to parse number strings into numeric values according to a specified pattern. The example parses a formatted number string into a numeric value.
const { parseNumber } = require('@progress/kendo-intl');
const numberString = '1,234,567.89';
const parsedNumber = parseNumber(numberString, 'n2');
console.log(parsedNumber); // Output: 1234567.89
Other packages similar to @progress/kendo-intl
intl
The 'intl' package provides the ECMAScript Internationalization API, which includes functionalities for date, number, and currency formatting, as well as parsing. It is a standard built-in object in JavaScript and is widely supported across different environments. Compared to @progress/kendo-intl, 'intl' is more basic but is natively supported in modern JavaScript environments.
moment
The 'moment' package is a popular library for parsing, validating, manipulating, and formatting dates in JavaScript. While it is primarily focused on date and time manipulation, it also supports internationalization. Compared to @progress/kendo-intl, 'moment' is more specialized in date and time operations but does not offer number and currency formatting.
date-fns
The 'date-fns' package provides a comprehensive set of functions for date manipulation and formatting. It is modular and allows you to import only the functions you need. 'date-fns' also supports internationalization. Compared to @progress/kendo-intl, 'date-fns' is more focused on date operations and offers a functional programming approach.
numeral
The 'numeral' package is a library for formatting and manipulating numbers. It supports various number formats, including currency and percentages. Compared to @progress/kendo-intl, 'numeral' is more specialized in number formatting and manipulation but does not offer date formatting functionalities.
![npm version](https://badge.fury.io/js/%40telerik%2Fkendo-intl.svg)
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 download the full CDLR database, you need to install the cldr-data module by running the following command.
npm install --save cldr-data
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-data/supplemental/likelySubtags.json"),
require("cldr-data/supplemental/currencyData.json"),
require("cldr-data/supplemental/weekData.json"),
require("cldr-data/main/bg/numbers.json"),
require("cldr-data/main/bg/currencies.json"),
require("cldr-data/main/bg/ca-gregorian.json"),
require("cldr-data/main/bg/dateFields.json"),
require("cldr-data/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"]);
parseDate("Montag, 6.11.2000", "EEEE, d.MM.y", "de");
parseDate("2000-11-06T10:30Z");
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");
formatDate(new Date(2000, 10, 6), "yMd", "de");
formatDate(new Date(2000, 10, 6), "EEEE, d.MM.y", "bg");
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");
parseNumber("1.212,22 €", "de");
parseNumber("10.22 %");
parseNumber("1,0000123e+4", "bg");
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");
formatNumber(1234.567, "c", "de");
formatNumber(1234.567, {
style: "currency",
currency: "USD",
currencyDisplay: "displayName"
}, "bg");
formatNumber(2345678, "##,#.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")
toString(10.5, "c", "bg");
toString(new Date(), "d");
For more examples and available configuration options, refer to the article on general formatting.
Installation
-
The Internationalization library is published as a scoped NPM package in the NPMJS Telerik account.
-
Download and install the module:
npm install --save '@progress/kendo-intl';
-
Once installed, import the Internationalization in your application root module:
import { formatDate, parseDate } from '@progress/kendo-intl';
import { formatNumber, parseNumber } from '@progress/kendo-intl';
var numbers = require('@progress/kendo-intl/number').numbers;
var dates = require('@progress/kendo-intl/dates').dates;