, T extends React_2.ComponentType = any>(WrappedComponent: React_2.ComponentType
, options?: Opts): React_2.ForwardRefExoticComponent> & React_2.RefAttributes> & {
WrappedComponent: React_2.ComponentType;
};
export declare interface IntlCache {
dateTime: Record;
number: Record;
message: Record;
relativeTime: Record;
pluralRules: Record;
list: Record;
displayNames: Record;
}
export declare interface IntlConfig {
locale: string;
timeZone?: string;
formats: CustomFormats;
textComponent?: React_2.ComponentType | keyof React_2.ReactHTML;
messages: Record | Record;
defaultLocale: string;
defaultFormats: CustomFormats;
wrapRichTextChunksInFragment?: boolean;
onError(err: ReactIntlError | FormatError): void;
}
export declare const IntlContext: React_2.Context;
export declare interface IntlFormatters {
formatDate(value: Parameters[0] | string, opts?: FormatDateOptions): string;
formatTime(value: Parameters[0] | string, opts?: FormatDateOptions): string;
formatDateToParts(value: Parameters[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
formatTimeToParts(value: Parameters[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
formatRelativeTime(value: Parameters[0], unit?: Parameters[1], opts?: FormatRelativeTimeOptions): string;
formatNumber(value: Parameters[0], opts?: FormatNumberOptions): string;
formatNumberToParts(value: Parameters[0], opts?: FormatNumberOptions): Intl.NumberFormatPart[];
formatPlural(value: Parameters[0], opts?: FormatPluralOptions): ReturnType;
formatMessage(descriptor: MessageDescriptor, values?: Record): string;
formatMessage(descriptor: MessageDescriptor, values?: Record>): string | React_2.ReactNodeArray;
formatList(values: Array, opts?: FormatListOptions): string;
formatList(values: Array, opts?: FormatListOptions): React_2.ReactNode;
formatDisplayName(value: Parameters[0], opts?: FormatDisplayNameOptions): string | undefined;
}
declare interface IntlListFormatOptions {
/**
* The locale matching algorithm to use.
* Possible values are "lookup" and "best fit"; the default is "best fit".
* For information about this option, see
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation.
*/
localeMatcher?: 'best fit' | 'lookup';
/**
* The format of output message. Possible values are:
* - "always" (default, e.g., 1 day ago),
* - or "auto" (e.g., yesterday).
* The "auto" value allows to not always have to
* use numeric values in the output.
*/
type?: 'conjunction' | 'disjunction' | 'unit';
/**
* The length of the internationalized message. Possible values are:
* - "long" (default, e.g., in 1 month)
* - "short" (e.g., in 1 mo.),
* - or "narrow" (e.g., in 1 mo.).
* The narrow style could be similar to the short style for some locales.
*/
style?: 'long' | 'short' | 'narrow';
}
declare class IntlMessageFormat {
private readonly ast;
private readonly locales;
private readonly formatters;
private readonly formats;
private readonly message;
private readonly formatterCache;
constructor(message: string | MessageFormatElement[], locales?: string | string[], overrideFormats?: Partial, opts?: Options);
format: (values?: Record | null | undefined> | undefined) => string | T | (string | T)[];
formatToParts: (values?: Record | null | undefined> | undefined) => MessageFormatPart[];
resolvedOptions: () => {
locale: string;
};
getAst: () => MessageFormatElement[];
private static memoizedDefaultLocale;
static get defaultLocale(): string;
static __parse: typeof parse | undefined;
static formats: {
number: {
currency: {
style: string;
};
percent: {
style: string;
};
};
date: {
short: {
month: string;
day: string;
year: string;
};
medium: {
month: string;
day: string;
year: string;
};
long: {
month: string;
day: string;
year: string;
};
full: {
weekday: string;
month: string;
day: string;
year: string;
};
};
time: {
short: {
hour: string;
minute: string;
};
medium: {
hour: string;
minute: string;
second: string;
};
long: {
hour: string;
minute: string;
second: string;
timeZoneName: string;
};
full: {
hour: string;
minute: string;
second: string;
timeZoneName: string;
};
};
};
}
export declare class IntlProvider extends React_2.PureComponent {
static displayName: string;
static defaultProps: Pick;
private cache;
state: State;
static getDerivedStateFromProps(props: OptionalIntlConfig, { prevConfig, cache }: State): Partial | null;
render(): JSX.Element;
}
declare interface IntlRelativeTimeFormatOptions {
/**
* The locale matching algorithm to use.
* Possible values are "lookup" and "best fit"; the default is "best fit".
* For information about this option, see
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation.
*/
localeMatcher?: 'best fit' | 'lookup';
/**
* The format of output message. Possible values are:
* - "always" (default, e.g., 1 day ago),
* - or "auto" (e.g., yesterday).
* The "auto" value allows to not always have to
* use numeric values in the output.
*/
numeric?: 'always' | 'auto';
/**
* The length of the internationalized message. Possible values are:
* - "long" (default, e.g., in 1 month)
* - "short" (e.g., in 1 mo.),
* - or "narrow" (e.g., in 1 mo.).
* The narrow style could be similar to the short style for some locales.
*/
style?: 'long' | 'short' | 'narrow';
}
export declare interface IntlShape extends IntlConfig, IntlFormatters {
formatters: Formatters;
}
declare interface IParseOptions {
filename?: string;
startRule?: string;
tracer?: any;
[key: string]: any;
}
declare type LanguageTag = string;
declare type LDMLPluralRule = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other';
declare class ListFormat {
constructor(locales?: string | string[], options?: IntlListFormatOptions);
format(elements: string[]): string;
formatToParts(elements: string[]): Part_2[];
resolvedOptions(): ResolvedIntlListFormatOptions;
static supportedLocalesOf(locales: string | string[], options?: Pick): string[];
static __addLocaleData(...data: ListPatternLocaleData[]): void;
static localeData: Record;
private static availableLocales;
private static __defaultLocale;
private static getDefaultLocale;
private static relevantExtensionKeys;
static polyfilled: boolean;
private static readonly __INTERNAL_SLOT_MAP__;
}
declare interface ListPattern {
start: string;
middle: string;
end: string;
pair: string;
}
declare interface ListPatternData {
long: ListPattern;
short?: ListPattern;
narrow?: ListPattern;
}
declare interface ListPatternFieldsData {
conjunction?: ListPatternData;
disjunction?: ListPatternData;
unit?: ListPatternData;
}
declare type ListPatternLocaleData = LocaleData;
declare type LiteralElement = BaseElement;
declare interface LiteralPart {
type: 'literal';
value: string;
}
declare interface LiteralPart_2 {
type: PART_TYPE.literal;
value: string;
}
declare type Locale = string;
declare interface LocaleData {
data: Record;
aliases: Record;
availableLocales: string[];
parentLocales: Record;
}
declare type LocaleFieldsData = {
[f in RelativeTimeField]?: FieldData;
} & {
nu?: Array;
};
declare interface Location_2 {
start: LocationDetails;
end: LocationDetails;
}
declare interface LocationDetails {
offset: number;
line: number;
column: number;
}
export declare interface MessageDescriptor {
id?: string | number;
description?: string | object;
defaultMessage?: string;
}
declare type MessageFormatElement = LiteralElement | ArgumentElement | NumberElement | DateElement | TimeElement | SelectElement | PluralElement | TagElement | PoundElement;
declare type MessageFormatPart = LiteralPart_2 | ObjectPart;
declare type NumberElement = SimpleFormatElement;
declare interface NumberFormatDigitOptions {
minimumIntegerDigits?: number;
minimumFractionDigits?: number;
maximumFractionDigits?: number;
minimumSignificantDigits?: number;
maximumSignificantDigits?: number;
}
declare interface NumberSkeleton {
type: SKELETON_TYPE.number;
tokens: NumberSkeletonToken[];
location?: Location_2;
}
declare interface NumberSkeletonToken {
stem: string;
options: string[];
}
declare interface ObjectPart {
type: PART_TYPE.object;
value: T;
}
declare type Omit_2 = Pick>;
export { Omit_2 as Omit }
declare type OptionalIntlConfig = Omit_2 & Partial;
declare interface Options {
formatters?: Formatters_2;
}
declare interface Options_2 {
/**
* Whether to convert `#` in plural rule options
* to `{var, number}`
* Default is true
*/
normalizeHashtagInPlural?: boolean;
/**
* Capture location info in AST
* Default is false
*/
captureLocation?: boolean;
}
declare interface Opts {
intlPropName?: IntlPropName;
forwardRef?: ForwardRef;
enforceContext?: boolean;
}
declare function parse(input: string, opts?: ParseOptions): MessageFormatElement[];
declare type ParseOptions = Options_2 & IParseOptions;
declare type Part = LiteralPart | RelativeTimeFormatNumberPart;
declare type Part_2 = LiteralPart | ElementPart;
declare const enum PART_TYPE {
literal = 0,
object = 1
}
declare interface PluralElement extends BaseElement {
options: Record;
offset: number;
pluralType: Intl.PluralRulesOptions['type'];
}
declare interface PluralOrSelectOption {
value: MessageFormatElement[];
location?: Location_2;
}
declare interface PoundElement {
type: TYPE.pound;
location?: Location_2;
}
declare type PrimitiveType = string | number | boolean | null | undefined | Date;
declare interface Props extends FormatRelativeTimeOptions {
value?: number;
unit?: Unit;
updateIntervalInSeconds?: number;
children?(value: string): React_2.ReactChild;
}
declare interface Props_2 extends FormatPluralOptions {
value: number;
intl: IntlShape;
other: React_2.ReactNode;
zero?: React_2.ReactNode;
one?: React_2.ReactNode;
two?: React_2.ReactNode;
few?: React_2.ReactNode;
many?: React_2.ReactNode;
children?(value: React_2.ReactNode): React_2.ReactElement | null;
}
declare interface Props_3 = Record> extends MessageDescriptor {
values?: V;
tagName?: React_2.ElementType;
children?(...nodes: React_2.ReactNodeArray): React_2.ReactNode;
}
export declare const RawIntlProvider: React_2.Provider;
export declare class ReactIntlError extends Error {
readonly code: ReactIntlErrorCode;
readonly descriptor?: MessageDescriptor;
constructor(code: ReactIntlErrorCode, message: string, descriptor?: MessageDescriptor, exception?: Error);
}
export declare const enum ReactIntlErrorCode {
FORMAT_ERROR = "FORMAT_ERROR",
UNSUPPORTED_FORMATTER = "UNSUPPORTED_FORMATTER",
INVALID_CONFIG = "INVALID_CONFIG",
MISSING_DATA = "MISSING_DATA",
MISSING_TRANSLATION = "MISSING_TRANSLATION"
}
declare type RegionCode = string;
declare type RelativeTimeData = {
[u in LDMLPluralRule]?: string;
};
declare type RelativeTimeField = 'second' | 'second-short' | 'second-narrow' | 'minute' | 'minute-short' | 'minute-narrow' | 'hour' | 'hour-short' | 'hour-narrow' | 'day' | 'day-short' | 'day-narrow' | 'week' | 'week-short' | 'week-narrow' | 'month' | 'month-short' | 'month-narrow' | 'quarter' | 'quarter-short' | 'quarter-narrow' | 'year' | 'year-short' | 'year-narrow';
declare class RelativeTimeFormat {
constructor(locales?: string | string[], options?: IntlRelativeTimeFormatOptions);
format(value: number, unit: FormattableUnit): string;
formatToParts(value: number, unit: FormattableUnit): Part[];
resolvedOptions(): ResolvedIntlRelativeTimeFormatOptions;
static supportedLocalesOf(locales: string | string[], options?: Pick): string[];
static __addLocaleData(...data: RelativeTimeLocaleData[]): void;
static localeData: Record;
private static availableLocales;
private static __defaultLocale;
private static getDefaultLocale;
private static relevantExtensionKeys;
static polyfilled: boolean;
private static readonly __INTERNAL_SLOT_MAP__;
}
declare interface RelativeTimeFormatNumberPart extends Intl.NumberFormatPart {
unit: Unit;
}
declare type RelativeTimeLocaleData = LocaleData;
declare interface ResolvedIntlListFormatOptions {
/**
* The BCP 47 language tag for the locale actually used.
* If any Unicode extension values were requested in the
* input BCP 47 language tag that led to this locale,
* the key-value pairs that were requested and are
* supported for this locale are included in locale.
*/
locale: string;
/**
* The format of output message. Possible values are:
* - "always" (default, e.g., 1 day ago),
* - or "auto" (e.g., yesterday).
* The "auto" value allows to not always have to
* use numeric values in the output.
*/
type: 'conjunction' | 'disjunction' | 'unit';
/**
* The length of the internationalized message. Possible values are:
* - "long" (default, e.g., in 1 month)
* - "short" (e.g., in 1 mo.),
* - or "narrow" (e.g., in 1 mo.).
* The narrow style could be similar to the short style for some locales.
*/
style: 'long' | 'short' | 'narrow';
}
declare interface ResolvedIntlRelativeTimeFormatOptions extends Pick {
/**
* The BCP 47 language tag for the locale actually used.
* If any Unicode extension values were requested in the
* input BCP 47 language tag that led to this locale,
* the key-value pairs that were requested and are
* supported for this locale are included in locale.
*/
locale: string;
/**
* The value requested using the Unicode
* extension key "nu" or filled in as a default.
*/
numberingSystem: string;
}
declare type ScriptCode = string;
declare interface SelectElement extends BaseElement {
options: Record;
}
declare interface SimpleFormatElement extends BaseElement {
style?: string | S | null;
}
declare type Skeleton = NumberSkeleton | DateTimeSkeleton;
declare const enum SKELETON_TYPE {
number = 0,
dateTime = 1
}
declare interface State {
/**
* Explicit intl cache to prevent memory leaks
*/
cache: IntlCache;
/**
* Intl object we created
*/
intl?: IntlShape;
/**
* list of memoized config we care about.
* This is important since creating intl is
* very expensive
*/
prevConfig: OptionalIntlConfig;
}
declare interface State_2 {
prevUnit?: Unit;
prevValue?: number;
currentValueInSeconds: number;
}
declare interface TagElement {
type: TYPE.tag;
value: string;
children: MessageFormatElement[];
location?: Location_2;
}
declare type TimeElement = SimpleFormatElement;
declare enum TYPE {
/**
* Raw text
*/
literal = 0,
/**
* Variable w/o any format, e.g `var` in `this is a {var}`
*/
argument = 1,
/**
* Variable w/ number format
*/
number = 2,
/**
* Variable w/ date format
*/
date = 3,
/**
* Variable w/ time format
*/
time = 4,
/**
* Variable w/ select format
*/
select = 5,
/**
* Variable w/ plural format
*/
plural = 6,
/**
* Only possible within plural argument.
* This is the `#` symbol that will be substituted with the count.
*/
pound = 7,
/**
* XML-like tag
*/
tag = 8
}
declare type UnifiedNumberFormatOptions = Intl.NumberFormatOptions & NumberFormatDigitOptions & {
localeMatcher?: UnifiedNumberFormatOptionsLocaleMatcher;
style?: UnifiedNumberFormatOptionsStyle;
compactDisplay?: UnifiedNumberFormatOptionsCompactDisplay;
currencyDisplay?: UnifiedNumberFormatOptionsCurrencyDisplay;
currencySign?: UnifiedNumberFormatOptionsCurrencySign;
notation?: UnifiedNumberFormatOptionsNotation;
signDisplay?: UnifiedNumberFormatOptionsSignDisplay;
unit?: Unit_2;
unitDisplay?: UnifiedNumberFormatOptionsUnitDisplay;
};
declare type UnifiedNumberFormatOptionsCompactDisplay = 'short' | 'long';
declare type UnifiedNumberFormatOptionsCurrencyDisplay = 'symbol' | 'code' | 'name' | 'narrowSymbol';
declare type UnifiedNumberFormatOptionsCurrencySign = 'standard' | 'accounting';
declare type UnifiedNumberFormatOptionsLocaleMatcher = 'lookup' | 'best fit';
declare type UnifiedNumberFormatOptionsNotation = 'standard' | 'scientific' | 'engineering' | 'compact';
declare type UnifiedNumberFormatOptionsSignDisplay = 'auto' | 'always' | 'never' | 'exceptZero';
declare type UnifiedNumberFormatOptionsStyle = 'decimal' | 'percent' | 'currency' | 'unit';
declare type UnifiedNumberFormatOptionsUnitDisplay = 'long' | 'short' | 'narrow';
declare type Unit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
declare type Unit_2 = 'degree' | 'acre' | 'hectare' | 'percent' | 'bit' | 'byte' | 'gigabit' | 'gigabyte' | 'kilobit' | 'kilobyte' | 'megabit' | 'megabyte' | 'petabyte' | 'terabit' | 'terabyte' | 'day' | 'hour' | 'millisecond' | 'minute' | 'month' | 'second' | 'week' | 'year' | 'centimeter' | 'foot' | 'inch' | 'kilometer' | 'meter' | 'mile-scandinavian' | 'mile' | 'millimeter' | 'yard' | 'gram' | 'kilogram' | 'ounce' | 'pound' | 'stone' | 'celsius' | 'fahrenheit' | 'fluid-ounce' | 'gallon' | 'liter' | 'milliliter';
declare type Units = 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'months' | 'quarters' | 'years';
declare type UnpackedLocaleFieldsData = {
[f in RelativeTimeField]?: FieldData;
} & {
nu: Array;
};
export declare function useIntl(): IntlShape;
declare type ValidPluralRule = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other' | string;
export declare type WithIntlProps = Omit_2
& {
forwardedRef?: React_2.Ref;
};
export declare type WrappedComponentProps = {
[k in IntlPropName]: IntlShape;
};
export { }