返回 DeepSeek-Reasonix
usageStatsFormat.ts
根目录 / desktop / frontend / src / lib / usageStatsFormat.ts
1 import { getLocale, type Locale } from "./i18n";
2
3 // formatUsageTokens follows the desktop language instead of leaking Chinese
4 // units into English UI. The explicit locale argument keeps the helper easy to
5 // verify while the default remains reactive through LocaleProvider rerenders.
6 export function formatUsageTokens(n: number, locale: Locale = getLocale()): string {
7 const languageTag = locale === "zh" ? "zh-CN" : locale;
8 return new Intl.NumberFormat(languageTag, {
9 notation: "compact",
10 maximumFractionDigits: 1,
11 }).format(n);
12 }
13
13 lines TYPESCRIPT