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.
51 lines (50 loc) • 3.46 kB
TypeScript
import { type NumberFormatOptions } from "@formatjs/ecma402-abstract";
import { type CustomFormatConfig, type FormatDateOptions, type FormatTimeOptions, type MessageDescriptor } from "@formatjs/intl";
import * as React from "react";
import { createIntl } from "./src/components/createIntl.js";
import FormattedDateTimeRange from "./src/components/dateTimeRange.js";
import injectIntl, { Context as IntlContext, Provider as RawIntlProvider, type WithIntlProps, type WrappedComponentProps } from "./src/components/injectIntl.js";
import FormattedMessage from "./src/components/message.js";
import FormattedPlural from "./src/components/plural.js";
import IntlProvider from "./src/components/provider.js";
import FormattedRelativeTime from "./src/components/relative.js";
import useIntl from "./src/components/useIntl.js";
import { type IntlShape } from "./src/types.js";
export { createIntlCache, type CustomFormatConfig, type CustomFormats, type FormatDateOptions, type FormatDisplayNameOptions, type FormatListOptions, type FormatNumberOptions, type FormatPluralOptions, type FormatRelativeTimeOptions, type Formatters, type IntlCache, type IntlFormatters, InvalidConfigError, type MessageDescriptor, MessageFormatError, MissingDataError, MissingTranslationError, IntlError as ReactIntlError, IntlErrorCode as ReactIntlErrorCode, UnsupportedFormatterError } from "@formatjs/intl";
export { type IntlConfig, type IntlShape, type ResolvedIntlConfig } from "./src/types.js";
export { createIntl, FormattedDateTimeRange, FormattedMessage, FormattedPlural, FormattedRelativeTime, injectIntl, IntlContext, IntlProvider, RawIntlProvider, useIntl, type WithIntlProps, type WrappedComponentProps };
export declare function defineMessages<
K extends keyof any,
T = MessageDescriptor,
U extends Record<K, T> = Record<K, T>
>(msgs: U): U;
export declare function defineMessage<T extends MessageDescriptor>(msg: T): T;
export declare const FormattedDate: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig<"date"> & {
value: string | number | Date | undefined;
children?(formattedDate: string): React.ReactElement | null;
}>;
export declare const FormattedTime: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig<"time"> & {
value: string | number | Date | undefined;
children?(formattedTime: string): React.ReactElement | null;
}>;
export declare const FormattedNumber: React.FC<Omit<NumberFormatOptions, "localeMatcher"> & CustomFormatConfig<"number"> & {
value: Parameters<IntlShape["formatNumber"]>[0];
children?(formattedNumber: string): React.ReactElement | null;
}>;
export declare const FormattedList: React.FC<Intl.ListFormatOptions & {
value: readonly React.ReactNode[];
}>;
export declare const FormattedDisplayName: React.FC<Intl.DisplayNamesOptions & {
value: string;
}>;
export declare const FormattedDateParts: React.FC<FormatDateOptions & {
value: Parameters<Intl.DateTimeFormat["format"]>[0] | string;
children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
}>;
export declare const FormattedTimeParts: React.FC<FormatTimeOptions & {
value: Parameters<Intl.DateTimeFormat["format"]>[0] | string;
children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
}>;
export type { MessageFormatElement } from "@formatjs/icu-messageformat-parser";
export type { PrimitiveType } from "intl-messageformat";
export { FormattedListParts, FormattedNumberParts } from "./src/components/createFormattedComponent.js";