@syncfusion/ej2-base
Version:
A common package of Essential JS 2 base libraries, methods and class definitions
284 lines (283 loc) • 8.9 kB
TypeScript
import { Observer } from './observer';
/**
* Specifies the observer used for external change detection.
*/
export declare const onIntlChange: Observer;
/**
* Specifies the default rtl status for EJ2 components.
*/
export declare let rightToLeft: boolean;
/**
* Interface for dateFormatOptions
*
*/
export interface DateFormatOptions {
/**
* Specifies the skeleton for date formatting.
*/
skeleton?: string;
/**
* Specifies the type of date formatting either date, dateTime or time.
*/
type?: string;
/**
* Specifies custom date formatting to be used.
*/
format?: string;
/**
* Specifies the calendar mode other than gregorian
*/
calendar?: string;
/**
* Enable server side date formating.
*/
isServerRendered?: boolean;
}
/**
* Interface for numberFormatOptions
*
*/
export interface NumberFormatOptions {
/**
* Specifies minimum fraction digits in formatted value.
*/
minimumFractionDigits?: number;
/**
* Specifies maximum fraction digits in formatted value.
*/
maximumFractionDigits?: number;
/**
* Specifies minimum significant digits in formatted value.
*/
minimumSignificantDigits?: number;
/**
* Specifies maximum significant digits in formatted value.
*/
maximumSignificantDigits?: number;
/**
* Specifies whether to use grouping or not in formatted value,
*/
useGrouping?: boolean;
/**
* Specifies whether to ignore currency symbol in formatted value,
*/
ignoreCurrency?: boolean;
/**
* Specifies the skeleton for perform formatting.
*/
skeleton?: string;
/**
* Specifies the currency code to be used for formatting.
*/
currency?: string;
/**
* Specifies minimum integer digits in formatted value.
*/
minimumIntegerDigits?: number;
/**
* Specifies custom number format for formatting.
*/
format?: string;
/**
* Species which currency symbol to consider.
*/
altSymbol?: string;
}
/**
* Specifies the CLDR data loaded for internationalization functionalities.
*
* @private
*/
export declare const cldrData: Object;
/**
* Specifies the default culture value to be considered.
*
* @private
*/
export declare let defaultCulture: string;
/**
* Internationalization class provides support to parse and format the number and date object to the desired format.
* ```typescript
* // To set the culture globally
* setCulture('en-GB');
*
* // To set currency code globally
* setCurrencyCode('EUR');
*
* //Load cldr data
* loadCldr(gregorainData);
* loadCldr(timeZoneData);
* loadCldr(numbersData);
* loadCldr(numberSystemData);
*
* // To use formatter in component side
* let Intl:Internationalization = new Internationalization();
*
* // Date formatting
* let dateFormatter: Function = Intl.getDateFormat({skeleton:'long',type:'dateTime'});
* dateFormatter(new Date('11/2/2016'));
* dateFormatter(new Date('25/2/2030'));
* Intl.formatDate(new Date(),{skeleton:'E'});
*
* //Number formatting
* let numberFormatter: Function = Intl.getNumberFormat({skeleton:'C5'})
* numberFormatter(24563334);
* Intl.formatNumber(123123,{skeleton:'p2'});
*
* // Date parser
* let dateParser: Function = Intl.getDateParser({skeleton:'short',type:'time'});
* dateParser('10:30 PM');
* Intl.parseDate('10',{skeleton:'H'});
* ```
*/
export declare class Internationalization {
culture: string;
constructor(cultureName?: string);
/**
* Returns the format function for given options.
*
* @param {DateFormatOptions} options - Specifies the format options in which the format function will return.
* @returns {Function} ?
*/
getDateFormat(options?: DateFormatOptions): Function;
/**
* Returns the format function for given options.
*
* @param {NumberFormatOptions} options - Specifies the format options in which the format function will return.
* @returns {Function} ?
*/
getNumberFormat(options?: NumberFormatOptions): Function;
/**
* Returns the parser function for given options.
*
* @param {DateFormatOptions} options - Specifies the format options in which the parser function will return.
* @returns {Function} ?
*/
getDateParser(options?: DateFormatOptions): Function;
/**
* Returns the parser function for given options.
*
* @param {NumberFormatOptions} options - Specifies the format options in which the parser function will return.
* @returns {Function} ?
*/
getNumberParser(options?: NumberFormatOptions): Function;
/**
* Returns the formatted string based on format options.
*
* @param {number} value - Specifies the number to format.
* @param {NumberFormatOptions} option - Specifies the format options in which the number will be formatted.
* @returns {string} ?
*/
formatNumber(value: number, option?: NumberFormatOptions): string;
/**
* Returns the formatted date string based on format options.
*
* @param {Date} value - Specifies the number to format.
* @param {DateFormatOptions} option - Specifies the format options in which the number will be formatted.
* @returns {string} ?
*/
formatDate(value: Date, option?: DateFormatOptions): string;
/**
* Returns the date object for given date string and options.
*
* @param {string} value - Specifies the string to parse.
* @param {DateFormatOptions} option - Specifies the parse options in which the date string will be parsed.
* @returns {Date} ?
*/
parseDate(value: string, option?: DateFormatOptions): Date;
/**
* Returns the number object from the given string value and options.
*
* @param {string} value - Specifies the string to parse.
* @param {NumberFormatOptions} option - Specifies the parse options in which the string number will be parsed.
* @returns {number} ?
*/
parseNumber(value: string, option?: NumberFormatOptions): number;
/**
* Returns Native Date Time Pattern
*
* @param {DateFormatOptions} option - Specifies the parse options for resultant date time pattern.
* @param {boolean} isExcelFormat - Specifies format value to be converted to excel pattern.
* @returns {string} ?
* @private
*/
getDatePattern(option: DateFormatOptions, isExcelFormat?: boolean): string;
/**
* Returns Native Number Pattern
*
* @param {NumberFormatOptions} option - Specifies the parse options for resultant number pattern.
* @param {boolean} isExcel ?
* @returns {string} ?
* @private
*/
getNumberPattern(option: NumberFormatOptions, isExcel?: boolean): string;
/**
* Returns the First Day of the Week
*
* @returns {number} ?
*/
getFirstDayOfWeek(): number;
/**
* Returns the culture
*
* @returns {string} ?
*/
private getCulture;
}
/**
* Set the default culture to all EJ2 components
*
* @param {string} cultureName - Specifies the culture name to be set as default culture.
* @returns {void} ?
*/
export declare function setCulture(cultureName: string): void;
/**
* Set the default currency code to all EJ2 components
*
* @param {string} currencyCode Specifies the culture name to be set as default culture.
* @returns {void} ?
*/
export declare function setCurrencyCode(currencyCode: string): void;
/**
* Load the CLDR data into context
*
* @param {Object[]} data Specifies the CLDR data's to be used for formatting and parser.
* @returns {void} ?
*/
export declare function loadCldr(...data: Object[]): void;
/**
* To enable or disable RTL functionality for all components globally.
*
* @param {boolean} status - Optional argument Specifies the status value to enable or disable rtl option.
* @returns {void} ?
*/
export declare function enableRtl(status?: boolean): void;
/**
* To get the numeric CLDR object for given culture
*
* @param {string} locale - Specifies the locale for which numericObject to be returned.
* @param {string} type ?
* @returns {Object} ?
* @ignore
* @private
*/
export declare function getNumericObject(locale: string, type?: string): Object;
/**
* To get the numeric CLDR number base object for given culture
*
* @param {string} locale - Specifies the locale for which numericObject to be returned.
* @param {string} currency - Specifies the currency for which numericObject to be returned.
* @returns {string} ?
* @ignore
* @private
*/
export declare function getNumberDependable(locale: string, currency: string): string;
/**
* To get the default date CLDR object.
*
* @param {string} mode ?
* @returns {Object} ?
* @ignore
* @private
*/
export declare function getDefaultDateObject(mode?: string): Object;