react-intl
Version:
Internationalize React apps. This library provides React components and an API to format dates, numbers, and strings, including pluralization and handling translations.
21 lines (20 loc) • 1.87 kB
TypeScript
import { IntlConfig, IntlCache, CustomFormats } from './types';
export declare function escape(str: string): string;
export declare function filterProps<T extends Record<string, any>, K extends string>(props: T, whitelist: Array<K>, defaults?: Partial<T>): Pick<T, K>;
export declare function invariantIntlContext(intl?: any): void;
export declare function createError(message: string, exception?: Error): string;
export declare function defaultErrorHandler(error: string): void;
export declare const DEFAULT_INTL_CONFIG: Pick<IntlConfig, 'formats' | 'messages' | 'timeZone' | 'textComponent' | 'defaultLocale' | 'defaultFormats' | 'onError'>;
export declare function createIntlCache(): IntlCache;
/**
* Create intl formatters and populate cache
* @param cache explicit cache to prevent leaking memory
*/
export declare function createFormatters(cache?: IntlCache): {
getDateTimeFormat: (locales?: string | string[] | undefined, options?: Intl.DateTimeFormatOptions | undefined) => any;
getNumberFormat: (locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined) => any;
getMessageFormat: (message: string | import("intl-messageformat-parser").MessageFormatElement[], locales?: string | string[] | undefined, overrideFormats?: Partial<import("intl-messageformat").Formats> | undefined, opts?: import("intl-messageformat").Options | undefined) => any;
getRelativeTimeFormat: (...args: unknown[]) => any;
getPluralRules: (locales?: string | string[] | undefined, options?: Intl.PluralRulesOptions | undefined) => any;
};
export declare function getNamedFormat<T extends keyof CustomFormats>(formats: CustomFormats, type: T, name: string, onError: (err: string) => void): Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | import("@formatjs/intl-relativetimeformat").IntlRelativeTimeFormatOptions | undefined;