Types
All types ship inside the package — no separate @types/localize-react install.
import type {
Translations,
TemplateValues,
Translate,
LocalizationContextValue,
LocalizationProviderProps,
MessageProps,
} from 'localize-react';
Translations​
A recursive interface — string leaves, nested branches.
interface Translations {
readonly [key: string]: string | Translations;
}
TemplateValues​
Values bound to {{placeholder}} tokens. Numbers are coerced to their String() form at render time.
type TemplateValues = Readonly<Record<string, string | number>>;
Translate​
type Translate = (
descriptor: string,
values?: TemplateValues,
defaultMessage?: string,
) => string;
Resolution: direct → dotted-path → defaultMessage → descriptor. Never throws.
LocalizationContextValue​
The value returned by useLocalize() and carried by the context.
interface LocalizationContextValue {
readonly locale: string | undefined;
readonly translate: Translate;
readonly translations: Translations;
}
LocalizationProviderProps​
interface LocalizationProviderProps {
readonly children?: ReactNode;
readonly locale?: string;
readonly translations: Translations;
readonly disableCache?: boolean;
}
MessageProps​
interface MessageProps {
readonly descriptor: string;
readonly values?: TemplateValues;
readonly defaultMessage?: string;
}
All props are readonly to match React's preferred prop-immutability story under strict + exactOptionalPropertyTypes.