UNPKG

@progress/kendo-angular-intl

Version:

Kendo UI Internationalization for Angular components

306 lines (305 loc) 13.1 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { EventEmitter } from '@angular/core'; import { DateFieldNameOptions, DateFormatOptions, DateFormatNameOptions, NumberFormatOptions, DateFormatPart, DayRange } from '@progress/kendo-intl'; import * as i0 from "@angular/core"; /** * @hidden */ export declare function cldrServiceFactory(localeId: string): CldrIntlService; /** * Represents the abstract base class for the Kendo UI for Angular Internationalization service. * Provides methods for formatting and parsing dates, numbers, and strings according to the current locale. * * Extend this class to implement custom internationalization logic or use the default CLDR-based implementation. */ export declare abstract class IntlService { /** * @hidden */ readonly changes: EventEmitter<any>; /** * @hidden */ constructor(); /** * Specifies that the service was changed. */ notify(): void; /** * 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. * @returns The formatted string. */ abstract format(format: string, ...values: any[]): string; /** * Converts an object into a string based on the specified format. * * @param value - The value to format. * @param format - The format to use. * @param localeId - The locale ID to use in place of the default (optional). * @returns The formatted object as a string. */ abstract toString(value: any, format: string | any, localeId?: string): string; /** * Converts a `Date` object into a string based on the specified format * ([see example]({% slug parsingandformatting_intl %}#toc-date-formatting)). * If no format is provided, the default short date format is used. * * @param value - The date to format. * @param format - The format string or options (optional). * @param localeId - The locale ID to use in place of the default (optional). * @returns The formatted date as a string. */ abstract formatDate(value: Date, format?: string | DateFormatOptions, localeId?: string): string; /** * Converts a string into a `Date` object based on the specified format. * * @param value - The string to convert. * @param format - The format strings or options (optional). * @param localeId - The locale ID to use in place of the default (optional). * @returns The parsed date. */ abstract parseDate(value: string, format?: string | DateFormatOptions | string[] | DateFormatOptions[], localeId?: string): Date; /** * Converts a string into a `Number`. * * @param value - The string to convert. * @param format - The format string or options (optional). * @param localeId - The locale ID to use in place of the default (optional). * @returns The parsed number. */ abstract parseNumber(value: string, format?: string | NumberFormatOptions, localeId?: string): number; /** * Converts a `Number` into a string based on the specified format. * * @param value - The number to format. * @param format - The format string or options. * @param localeId - The locale ID to use in place of the default (optional). * @returns The formatted number as a string. */ abstract formatNumber(value: number, format: string | NumberFormatOptions, localeId?: string): string; /** * Returns the day names from the current locale based on the option. * * @param options - Detailed configuration for the desired date format. * @param localeId - The locale ID to use in place of the default (optional). * @returns The day names from the current locale based on the option. */ abstract dateFormatNames(options: DateFormatNameOptions, localeId?: string): any; /** * Returns a localized date field name based on specific `dateFieldName` options. * * @param options - Detailed configuration for the desired date field name. * @param localeId - The locale ID to use (optional). If not specified, the `"en"` locale ID is used. * @returns The localized date field name from the current locale based on the option. * * @example * ```ts * dateFieldName({ type: 'day' }); //returns 'day'; * dateFieldName({ type: 'day', nameType: 'wide' }); //returns 'day'; * dateFieldName({ type: 'month', nameType: 'short' }); //returns 'mo.'; * dateFieldName({ type: 'month', nameType: 'wide' }); //returns 'month'; * ``` */ abstract dateFieldName(options: DateFieldNameOptions, localeId?: string): string; /** * Splits the date format into objects containing information about each part of the pattern. * * @param format - The format string or options. * @param localeId - The locale ID to use (optional). If not specified, the `"en"` locale ID is used. * @returns The date format parts. */ abstract splitDateFormat(format: string | DateFormatOptions, localeId?: string): DateFormatPart[]; /** * Returns the number symbols from the current locale based on the option. * * @param localeId - The locale ID to use in place of the default one (optional). * @returns The number symbols from the current locale. */ abstract numberSymbols(localeId?: string): any; /** * Returns the first day index starting from Sunday. * * @param localeId - The locale ID (optional). Defaults to the current locale ID. * @returns The index of the first day of the week (0 == Sunday). */ abstract firstDay(localeId?: string): number; /** * Returns the start and end index of the locale weekend starting from Sunday. * * @param localeId - The locale ID (optional). Defaults to the current locale ID. * @returns The start and end index of the locale weekend (0 == Sunday). */ abstract weekendRange(localeId?: string): DayRange; static ɵfac: i0.ɵɵFactoryDeclaration<IntlService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<IntlService>; } /** * Represents the Internationalization service implemented using the CLDR Database via the `@progress/kendo-intl` package. * Provides locale-aware formatting and parsing for dates, numbers, and strings. * * @example * ```ts * import { CldrIntlService } from '@progress/kendo-angular-intl'; * const intl = new CldrIntlService('en-US'); * intl.formatDate(new Date(), { date: 'short' }); * ``` */ export declare class CldrIntlService extends IntlService { private locale; /** * Specifies or gets the current locale ID. */ get localeId(): string; set localeId(value: string); /** * Creates a new instance of the service with the ID of the specified locale. * * Note that the parts of the locale ID can be separated by either `_` (underscore) * or `-` (dash). * * @param localeId - The default locale ID. */ constructor(localeId: 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. * @returns The formatted string. */ format(format: string, ...values: any[]): string; /** * Converts an object into a string based on the specified format. * * @param value - The value to format. * @param format - The format to use. * @param localeId - The locale ID to use in place of the default one (optional). * @returns The formatted object as a string. */ toString(value: any, format: string | any, localeId?: string): string; /** * Converts a `Date` object into a string based on the specified format. * If no format is provided, the default short date format is used. * * @param value - The date to format. * @param format - The format string or options (optional). * @param localeId - The locale ID to use in place of the default one (optional). * @returns The formatted date as a string. */ formatDate(value: Date, format?: string | DateFormatOptions, localeId?: string): string; /** * Converts a string into a `Date` object based on the specified format. * * @param value - The string to convert. * @param format - The format strings or options (optional). * @param localeId - The locale ID to use in place of the default one (optional). * @returns The parsed date. */ parseDate(value: string, format?: string | DateFormatOptions | string[] | DateFormatOptions[], localeId?: string): Date; /** * Converts a string into a `Number`. * * @param value - The string to convert. * @param format - The format string or options (optional). * @param localeId - The locale ID to use in place of the default one (optional). * @returns The parsed number. */ parseNumber(value: string, format?: string | NumberFormatOptions, localeId?: string): number; /** * Converts a `Number` into a string based on the specified format. * * @param value - The number to format. * @param format - The format string or options. * @param localeId - The locale ID to use in place of the default one (optional). * @returns The formatted number as a string. */ formatNumber(value: number, format: string | NumberFormatOptions, localeId?: string): string; /** * Returns the date names from the current locale based on the option. * * The available `type` values are: * - `era` * - `year` * - `quarter` * - `month` * - `week` * - `day` * - `dayperiod` * - `hour` * - `minute` * - `second` * - `zone` * * The available `nameType` values are: * - `wide` * - `narrow` * - `short` * * @param options - Detailed configuration for the desired date field name. * @param localeId - The locale ID to use in place of the default one (optional). * @returns The day names from the current locale based on the option. * * @example * ```ts * dateFieldName({ type: 'day' }); //returns 'day'; * dateFieldName({ type: 'day', nameType: 'wide' }); //returns 'day'; * dateFieldName({ type: 'month', nameType: 'short' }); //returns 'mo.'; * dateFieldName({ type: 'month', nameType: 'wide' }); //returns 'month'; * ``` */ dateFieldName(options: DateFieldNameOptions, localeId?: string): string; /** * Returns a localized date field name based on specific `dateFieldName` options. * * The available type values are: * - `day` * - `dayperiod` * - `months` * - `quarters` * - `eras` * * @param options - Detailed configuration for the desired date format. * @param localeId - The locale ID to use in place of the default one (optional). * @returns The day names from the current locale based on the option. */ dateFormatNames(options: DateFormatNameOptions, localeId?: string): any; /** * Splits the date format into objects containing information about each part of the pattern. * * @param format - The format string or options. * @param localeId - The locale ID to use (optional). If not specified, the `"en"` locale ID is used. * @returns The date format parts. */ splitDateFormat(format: string | DateFormatOptions, localeId?: string): DateFormatPart[]; /** * Returns the number symbols from the current locale based on the option. * * @param localeId - The locale ID to use in place of the default one (optional). * @returns The number symbols from the current locale. */ numberSymbols(localeId?: string): any; /** * Returns the first day index starting from Sunday. * * @param localeId - The locale ID (optional). Defaults to the current locale ID. * @returns The index of the first day of the week (0 == Sunday). */ firstDay(localeId?: string): number; /** * Returns the start and end index of the locale weekend starting from Sunday. * * @param localeId - The locale ID (optional). Defaults to the current locale ID. * @returns The start and end index of the locale weekend (0 == Sunday). */ weekendRange(localeId?: string): DayRange; static ɵfac: i0.ɵɵFactoryDeclaration<CldrIntlService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<CldrIntlService>; }