const LATIN_TO_PERSIAN: Record = { "0": "۰", "1": "۱", "2": "۲", "3": "۳", "4": "۴", "5": "۵", "6": "۶", "7": "۷", "8": "۸", "9": "۹", }; /** * Convert Latin digits in a string to Persian digits. * Leaves non-digit characters unchanged. Use for UI labels, stats, * dates, and counters — not for technical IDs or code. */ export function toPersianDigits(value: string | number): string { return String(value).replace(/[0-9]/g, (digit) => LATIN_TO_PERSIAN[digit] ?? digit); } /** * Format a number for Persian UI (locale grouping + Persian digits). */ export function formatPersianNumber( value: number, options?: Intl.NumberFormatOptions ): string { return toPersianDigits( new Intl.NumberFormat("fa-IR", options).format(value) ); }