Build & Push Docker Image / build (push) Has been cancelled
Refresh the homepage around new hero/services/roadmap sections, shared design tokens, and updated brand assets. Co-authored-by: Cursor <cursoragent@cursor.com>
34 lines
802 B
TypeScript
34 lines
802 B
TypeScript
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)
|
||
);
|
||
}
|