@progress/kendo-react-intl
Version:
React Internationalization package provides services for parsing and formatting of dates and numbers. KendoReact Internationalization package
138 lines (137 loc) • 4.18 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import * as e from "@progress/kendo-intl";
class o {
/**
* Creates a new instance of the internationalization service.
*
* @param locale - The locale that will be used by the internationalization methods.
*/
constructor(r) {
if (this.locale = r, r === "" && process.env.NODE_ENV !== "production")
throw "Locale should not be empty string";
}
/**
* Formats a string with placeholders such as `Total amount {0:c}`.
*
* @param format - The format string.
* @param values - One or more values to output in the format string placeholders.
* @return - The formatted string.
*/
format(r, ...t) {
return t.length === 1 && Array.isArray(t[0]) ? e.format(r, t[0], this.locale) : e.format(r, t, this.locale);
}
/**
* Converts a `Date` object to a string based on the specified format. If no format is provided, the default short date format is used.
*
* @param value - The date which will be formatted.
* @param format - The format string or options.
* @return - The formatted date.
*/
formatDate(r, t) {
return e.formatDate(r, t, this.locale);
}
/**
* Converts an object to a string based on the specified format.
*
* @param value - The value which will be formatted.
* @param format - The format to use.
* @return - The formatted object.
*/
toString(r, t) {
return e.toString(r, t, this.locale);
}
/**
* Converts a string to a `Number`.
*
* @param value - The string which will be parsed.
* @param format - The format string or options.
* @return - The parsed number.
*/
parseNumber(r, t) {
return e.parseNumber(r, this.locale, t);
}
/**
* Converts a string to a `Date` object based on the specified format.
*
* @param value - The string which will be converted.
* @param format - The format strings or options.
* @return - The parsed date.
*/
parseDate(r, t) {
return e.parseDate(r, t, this.locale);
}
/**
* Converts a `Number` to a string based on the specified format.
*
* @param value - The number which will be formatted.
* @param format - The format string or options.
* @return - The formatted number.
*/
formatNumber(r, t) {
return e.formatNumber(r, t, this.locale);
}
/**
* Returns a localized date field name based on specific `dateFieldName` options.
*
* @param options - The detailed configuration for the desired date field name.
* @returns - The localized date field name from the current locale based on the option.
*/
dateFieldName(r) {
return e.dateFieldName(r, this.locale);
}
/**
* Returns the day names from the current locale based on the option.
*
* @param options - The detailed configuration for the desired date format.
* @return - The day names from the current locale based on the option.
*/
dateFormatNames(r) {
return e.dateFormatNames(this.locale, r);
}
/**
* Splits the date format into objects which contain information about each part of the pattern.
*
* @param format - The format string or options.
* @returns - The date format parts.
*/
splitDateFormat(r) {
return e.splitDateFormat(r, this.locale);
}
/**
* Returns the number symbols from the current locale.
*
* @return - The number symbols from the current locale.
*/
numberSymbols() {
return e.numberSymbols(this.locale);
}
/**
* Returns the first day index, starting from Sunday.
*
* @return - The index of the first day of the week (0 == Sunday).
*/
firstDay() {
return e.firstDay(this.locale);
}
/**
* @hidden
*/
localeInfo() {
return e.localeInfo(this.locale);
}
/**
* @hidden
*/
localeCurrency() {
return e.localeCurrency(this.locale);
}
}
export {
o as IntlService
};