Files
aragrp/lib/persian-digits.ts
ar.badieiandCursor c2376b3b9e
Build & Push Docker Image / build (push) Has been cancelled
feat: redesign landing page with brand system and section blocks
Refresh the homepage around new hero/services/roadmap sections, shared design tokens, and updated brand assets.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-23 17:00:55 +03:30

34 lines
802 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const LATIN_TO_PERSIAN: Record<string, string> = {
"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)
);
}