@shelchin/svelte-i18n
Version:
The last Svelte i18n library you'll ever need. Type-safe, AI-powered, zero-config.
84 lines (83 loc) • 2.96 kB
TypeScript
/**
* Unified formatter using native Intl API
* Supports all major locales with minimal code
*/
/**
* Format numbers with locale-specific rules
*/
export declare function formatNumber(value: number, locale: string, options?: Intl.NumberFormatOptions): string;
/**
* Format currency with locale-specific rules
*/
export declare function formatCurrency(value: number, locale: string, currency?: string, options?: Intl.NumberFormatOptions): string;
/**
* Format dates with locale-specific rules
*/
export declare function formatDate(date: Date | number | string, locale: string, options?: Intl.DateTimeFormatOptions): string;
/**
* Format time with locale-specific rules
*/
export declare function formatTime(date: Date | number | string, locale: string, options?: Intl.DateTimeFormatOptions): string;
/**
* Format relative time (e.g., "2 days ago", "in 3 hours")
*/
export declare function formatRelativeTime(value: number, unit: Intl.RelativeTimeFormatUnit, locale: string, options?: Intl.RelativeTimeFormatOptions): string;
/**
* Format lists (e.g., "A, B, and C")
*/
export declare function formatList(items: string[], locale: string, type?: 'conjunction' | 'disjunction' | 'unit'): string;
/**
* Preset formats for common use cases
*/
export declare const FORMATS: {
readonly number: {
readonly default: {};
readonly decimal: {
readonly minimumFractionDigits: 2;
readonly maximumFractionDigits: 2;
};
readonly percent: {
readonly style: "percent";
};
readonly compact: {
readonly notation: "compact";
};
readonly scientific: {
readonly notation: "scientific";
};
readonly engineering: {
readonly notation: "engineering";
};
};
readonly date: {
readonly short: Intl.DateTimeFormatOptions;
readonly medium: Intl.DateTimeFormatOptions;
readonly long: Intl.DateTimeFormatOptions;
readonly full: Intl.DateTimeFormatOptions;
readonly yearMonth: Intl.DateTimeFormatOptions;
readonly monthDay: Intl.DateTimeFormatOptions;
readonly weekday: Intl.DateTimeFormatOptions;
};
readonly time: {
readonly short: Intl.DateTimeFormatOptions;
readonly medium: Intl.DateTimeFormatOptions;
readonly long: Intl.DateTimeFormatOptions;
readonly hour: Intl.DateTimeFormatOptions;
readonly hourMinute: Intl.DateTimeFormatOptions;
readonly hourMinuteSecond: Intl.DateTimeFormatOptions;
};
readonly dateTime: {
readonly short: {
readonly dateStyle: "short";
readonly timeStyle: "short";
};
readonly medium: {
readonly dateStyle: "medium";
readonly timeStyle: "medium";
};
readonly long: {
readonly dateStyle: "long";
readonly timeStyle: "long";
};
};
};