@scaleway/use-i18n
Version:
A small hook to handle i18n
23 lines (22 loc) • 1.09 kB
TypeScript
import type { NumberFormatOptions } from '@formatjs/ecma402-abstract';
import IntlTranslationFormat from 'intl-messageformat';
export type IntlListFormatOptions = {
localeMatcher?: 'best fit' | 'lookup';
type?: 'conjunction' | 'disjunction' | 'unit';
style?: 'long' | 'short' | 'narrow';
};
declare abstract class IntlListFormat {
constructor(locales?: string | string[], options?: IntlListFormatOptions);
format: (items: string[]) => string;
}
type BaseFormatters = {
getNumberFormat(locales?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat;
getDateTimeFormat(...args: ConstructorParameters<typeof Intl.DateTimeFormat>): Intl.DateTimeFormat;
getPluralRules(...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
getListFormat(...args: ConstructorParameters<typeof IntlListFormat>): IntlListFormat;
};
type Formatters = BaseFormatters & {
getTranslationFormat(...args: ConstructorParameters<typeof IntlTranslationFormat>): IntlTranslationFormat;
};
declare const formatters: Formatters;
export default formatters;