/** * ICU MessageFormat integration. * * Provides automatic parsing and formatting of ICU MessageFormat syntax: * - Pluralization: {count, plural, one {# item} other {# items}} * - Selection: {gender, select, male {he} female {she} other {they}} * - Number formatting: {price, number, currency} * - Date formatting: {date, date, short} * * @module i18n/icu * * @example Pluralization * ```typescript * const message = "{count, plural, one {You have # item} other {You have # items}}"; * const format = compileICU(message, 'en'); * format({ count: 1 }); // "You have 1 item" * format({ count: 5 }); // "You have 5 items" * ``` * * @example Selection (Gender) * ```typescript * const message = "{gender, select, male {He is} female {She is} other {They are}} online"; * const format = compileICU(message, 'en'); * format({ gender: 'male' }); // "He is online" * format({ gender: 'female' }); // "She is online" * ``` * * @example Number Formatting * ```typescript * const message = "Price: {price, number, ::currency/USD}"; * const format = compileICU(message, 'en-US'); * format({ price: 1234.56 }); // "Price: $1,234.56" * ``` */ /** * Compiled ICU message function. */ export type ICUMessageFunction = (params: Record) => string; /** * Detect if a string contains ICU MessageFormat syntax. * * Checks for patterns like: * - {variable, plural, ...} * - {variable, select, ...} * - {variable, number, ...} * - {variable, date, ...} * - {variable, time, ...} * * @param str - String to check * @returns true if string contains ICU syntax * * @example * ```typescript * isICUMessage("Hello {name}"); // false (simple interpolation) * isICUMessage("{count, plural, one {# item} other {# items}}"); // true * isICUMessage("{gender, select, male {he} female {she}}"); // true * ``` */ export declare function isICUMessage(str: string): boolean; /** * Compile an ICU MessageFormat string into a function. * * The compiled function can be called with parameters to produce * the formatted message. * * @param message - ICU MessageFormat string * @param locale - Locale for formatting rules * @returns Compiled message function * * @example Basic Pluralization * ```typescript * const format = compileICU( * "{count, plural, one {# item} other {# items}}", * 'en' * ); * format({ count: 1 }); // "1 item" * format({ count: 5 }); // "5 items" * ``` * * @example Complex Nested * ```typescript * const format = compileICU( * "{gender, select, male {{count, plural, one {He has # item} other {He has # items}}} female {{count, plural, one {She has # item} other {She has # items}}}}", * 'en' * ); * format({ gender: 'male', count: 1 }); // "He has 1 item" * format({ gender: 'female', count: 5 }); // "She has 5 items" * ``` */ export declare function compileICU(message: string, locale: string): ICUMessageFunction; /** * Clear the ICU message cache. * * Useful when: * - Changing locales dynamically * - Hot reloading translations in development * - Testing * * @param locale - Optional locale to clear (clears all if not specified) * * @example * ```typescript * // Clear all cached messages * clearICUCache(); * * // Clear only English messages * clearICUCache('en'); * ``` */ export declare function clearICUCache(locale?: string): void; /** * Get cache statistics. * * Useful for monitoring and debugging. * * @returns Object with cache size */ export declare function getICUCacheStats(): { size: number; }; /** * Common ICU patterns for reference. * * These examples show the most common ICU MessageFormat patterns. */ export declare const ICUPatterns: { /** * Simple pluralization (English-style: one vs other) */ simplePlural: string; /** * Complex pluralization (Polish-style: one, few, many, other) */ complexPlural: string; /** * Arabic pluralization (6 forms!) */ arabicPlural: string; /** * Gender selection */ genderSelect: string; /** * Nested gender + plural */ nestedGenderPlural: string; /** * Number formatting as currency */ currency: string; /** * Number formatting as percent */ percent: string; /** * Date formatting */ date: string; /** * Time formatting */ time: string; /** * Ordinal selection (1st, 2nd, 3rd, ...) */ ordinal: string; }; /** * Locale-specific plural rules reference. * * Different languages have different plural categories. */ export declare const PluralRules: { /** * English, German, Dutch, Swedish, Norwegian, Danish, Italian, Spanish, Portuguese * Forms: one, other */ english: string[]; /** * Polish, Russian, Ukrainian, Czech, Slovak * Forms: one, few, many, other */ slavic: string[]; /** * Arabic * Forms: zero, one, two, few, many, other */ arabic: string[]; /** * Chinese, Japanese, Korean, Vietnamese, Thai * Forms: other (no plural distinction) */ asian: string[]; /** * French, Portuguese (Brazilian) * Forms: one, other (but "one" includes 0 and 1) */ romance: string[]; }; //# sourceMappingURL=icu.d.ts.map