Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix(prompts): format numbers in en-US whatever the browser locale is (#1095)

Cihaneb23e518aefe
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/prompts/_charts.tsx b/web/src/app/[locale]/(dashboard)/dashboard/prompts/_charts.tsx
index 6ce39b85b..070fe7d22 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/prompts/_charts.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/prompts/_charts.tsx
@@ -2,7 +2,7 @@
import { useRef, useState, useEffect } from 'react';
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Cell } from 'recharts';
-import { formatCompactNumber } from '@/lib/format';
+import { formatCompactNumber, formatNumber } from '@/lib/format';
// ─── Auto-sizing wrapper ─────────────────────────────────────────────────────
@@ -129,9 +129,7 @@ export function PlatformVolumeChart({ totalVolume }: { totalVolume: number }) {
<p className="font-medium text-foreground mb-0.5">{row.name}</p>
<p className="text-muted-foreground">
Est. queries:{' '}
- <span className="font-medium text-foreground">
- {row.volume.toLocaleString()}
- </span>
+ <span className="font-medium text-foreground">{formatNumber(row.volume)}</span>
</p>
<p className="text-muted-foreground">
Share:{' '}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/prompts/_suggestions-card.tsx b/web/src/app/[locale]/(dashboard)/dashboard/prompts/_suggestions-card.tsx
index 3613be96d..881b09506 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/prompts/_suggestions-card.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/prompts/_suggestions-card.tsx
@@ -34,6 +34,7 @@ import {
} from '@/components/ui/select';
import { toast } from 'sonner';
import { cn } from '@/lib/utils';
+import { formatNumber } from '@/lib/format';
import {
getPromptSuggestions,
refreshPromptSuggestions,
@@ -58,17 +59,17 @@ function gaEvidence(d: GaSuggestionSourceData): { label: string; tooltip: string
if (d.kind === 'ai_momentum') {
const engines = d.aiPlatforms.length ? d.aiPlatforms.join(', ') : 'AI assistants';
return {
- label: `AI traffic · ${d.aiSessions.toLocaleString()} sessions`,
- tooltip: `${engines} already sent ${d.aiSessions.toLocaleString()} visits to ${d.landingPage} in the last 28 days. That topic is demonstrably answerable by an AI engine and you are already a candidate source for it — tracking a prompt around it turns an accident into a measured position.`,
+ label: `AI traffic · ${formatNumber(d.aiSessions)} sessions`,
+ tooltip: `${engines} already sent ${formatNumber(d.aiSessions)} visits to ${d.landingPage} in the last 28 days. That topic is demonstrably answerable by an AI engine and you are already a candidate source for it — tracking a prompt around it turns an accident into a measured position.`,
};
}
const earns =
d.revenue > 0
- ? `${d.revenue.toLocaleString()} in revenue`
- : `${d.keyEvents.toLocaleString()} conversions`;
+ ? `${formatNumber(d.revenue)} in revenue`
+ : `${formatNumber(d.keyEvents)} conversions`;
return {
label: `#${d.rank} by ${d.revenue > 0 ? 'revenue' : 'conversions'}`,
- tooltip: `${d.landingPage} produced ${earns} from ${d.sessions.toLocaleString()} sessions in the last 28 days, and nothing you track would surface it in an AI answer. Anyone asking an assistant about this has no way to find you.`,
+ tooltip: `${d.landingPage} produced ${earns} from ${formatNumber(d.sessions)} sessions in the last 28 days, and nothing you track would surface it in an AI answer. Anyone asking an assistant about this has no way to find you.`,
};
}
@@ -152,7 +153,7 @@ function SourceBadges({ suggestion }: { suggestion: PromptSuggestion }) {
<div className="flex flex-wrap items-center gap-1.5">
{gsc && (
<HoverTip
- content={`From your Google Search Console data — the query "${gsc.query}" got ${gsc.impressions.toLocaleString()} impressions in the last 28 days.`}
+ content={`From your Google Search Console data — the query "${gsc.query}" got ${formatNumber(gsc.impressions)} impressions in the last 28 days.`}
>
<Badge variant="outline" className="gap-1.5 bg-card text-xs font-normal">
<SearchCheck className="h-3.5 w-3.5 text-blue-500" />
@@ -597,7 +598,7 @@ export function SuggestionsCard({ brandId, onAccepted, sourceStates }: Props) {
className="gap-1 text-xs font-normal tabular-nums"
>
<TrendingUp className="h-3 w-3" />
- {gsc.impressions.toLocaleString()} impr/mo
+ {formatNumber(gsc.impressions)} impr/mo
</Badge>
) : ga ? (
<HoverTip content={gaEvidence(ga).tooltip}>
@@ -616,7 +617,7 @@ export function SuggestionsCard({ brandId, onAccepted, sourceStates }: Props) {
variant="outline"
className="gap-1 text-xs font-normal tabular-nums"
>
- <TrendingUp className="h-3 w-3" />~{s.estVolume.toLocaleString()}/mo
+ <TrendingUp className="h-3 w-3" />~{formatNumber(s.estVolume)}/mo
</Badge>
)
)}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx
index 3a992a1fd..5ec46a6f6 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx
@@ -163,7 +163,7 @@ import { toCsv } from '@/lib/csv';
import { formatRelative } from '@/lib/format-relative';
import { compareNullsLast, type SortDir } from './prompt-sort';
import { BulkActionBar } from './_bulk-action-bar';
-import { formatCompactNumber } from '@/lib/format';
+import { formatCompactNumber, formatNumber } from '@/lib/format';
import { usePagination, TablePager } from '@/components/table-pager';
import { PromptPositionsSheet } from '@/components/prompts/prompt-positions-sheet';
import {
@@ -2217,7 +2217,7 @@ export default function PromptsPage() {
</TableCell>
<TableCell className="text-right tabular-nums text-sm text-muted-foreground">
- {row.totalGoogleVolume.toLocaleString()}
+ {formatNumber(row.totalGoogleVolume)}
</TableCell>
<TableCell className="text-right">
<VolumePill value={row.estAiVolume} />
@@ -3455,14 +3455,14 @@ function AllPromptsTab({
</TableCell>
<TableCell className="text-right tabular-nums text-sm">
{vis ? (
- vis.totalMentions.toLocaleString()
+ formatNumber(vis.totalMentions)
) : (
<span className="text-xs text-muted-foreground">—</span>
)}
</TableCell>
<TableCell className="text-right tabular-nums text-sm">
{vis ? (
- vis.totalCitations.toLocaleString()
+ formatNumber(vis.totalCitations)
) : (
<span className="text-xs text-muted-foreground">—</span>
)}
@@ -3506,7 +3506,7 @@ function AllPromptsTab({
</TableCell>
<TableCell className="text-right tabular-nums text-sm">
{vis ? (
- vis.runs.toLocaleString()
+ formatNumber(vis.runs)
) : (
<span className="text-xs text-muted-foreground">—</span>
)}
diff --git a/web/src/components/prompts/bulk-import-prompts.tsx b/web/src/components/prompts/bulk-import-prompts.tsx
index cfabdb258..42142403b 100644
--- a/web/src/components/prompts/bulk-import-prompts.tsx
+++ b/web/src/components/prompts/bulk-import-prompts.tsx
@@ -14,6 +14,7 @@ import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { cn } from '@/lib/utils';
import { toCsv } from '@/lib/csv';
+import { formatNumber } from '@/lib/format';
import { importPrompts } from '@/lib/actions/prompt';
import {
MAX_IMPORT_ROWS,
@@ -204,7 +205,7 @@ export function BulkImportPrompts({
{fileName ?? 'Drop an .xlsx or .csv file, or click to browse'}
</p>
<p className="text-xs text-muted-foreground">
- One prompt per row · up to {MAX_IMPORT_ROWS.toLocaleString()} rows
+ One prompt per row · up to {formatNumber(MAX_IMPORT_ROWS)} rows
</p>
<input
ref={inputRef}
@@ -245,8 +246,8 @@ export function BulkImportPrompts({
</p>
{preview.truncated > 0 && (
<p className="text-xs text-amber-700 dark:text-amber-400">
- Only the first {MAX_IMPORT_ROWS.toLocaleString()} rows were read;{' '}
- {preview.truncated.toLocaleString()} more were left out. Split larger files.
+ Only the first {formatNumber(MAX_IMPORT_ROWS)} rows were read;{' '}
+ {formatNumber(preview.truncated)} more were left out. Split larger files.
</p>
)}
{preview.extraColumns && (
diff --git a/web/src/lib/format.test.ts b/web/src/lib/format.test.ts
new file mode 100644
index 000000000..51c36752a
--- /dev/null
+++ b/web/src/lib/format.test.ts
@@ -0,0 +1,48 @@
+/**
+ * format.test.ts
+ *
+ * The browser's default locale is simulated as Turkish (tr-TR), which uses "."
+ * for thousands and "," for decimals — the setup where a prompt's 1,232
+ * mentions used to read as "1.232" on the Prompts page.
+ */
+
+import { afterEach, beforeEach, expect, test, vi } from 'vitest';
+import { formatCompactNumber, formatNumber } from './format.js';
+
+const toLocaleString = Number.prototype.toLocaleString;
+
+beforeEach(() => {
+ vi.spyOn(Number.prototype, 'toLocaleString').mockImplementation(function (
+ this: number,
+ locales?: Intl.LocalesArgument,
+ options?: Intl.NumberFormatOptions,
+ ) {
+ return toLocaleString.call(this, locales ?? 'tr-TR', options);
+ });
+});
+
+afterEach(() => {
+ vi.restoreAllMocks();
+});
+
+test('the simulated browser locale is Turkish', () => {
+ expect((1232).toLocaleString()).toBe('1.232');
+});
+
+test('formatNumber uses English separators whatever the browser locale is', () => {
+ expect(formatNumber(1232)).toBe('1,232');
+ expect(formatNumber(1_234_567)).toBe('1,234,567');
+ expect(formatNumber(1234.5)).toBe('1,234.5');
+ expect(formatNumber(0)).toBe('0');
+});
+
+test('formatCompactNumber keeps decimals below 1,000 in English', () => {
+ expect(formatCompactNumber(512.25)).toBe('512.25');
+ expect(formatCompactNumber(999)).toBe('999');
+});
+
+test('formatCompactNumber abbreviates from 1,000 up', () => {
+ expect(formatCompactNumber(1232)).toBe('1.2k');
+ expect(formatCompactNumber(2_500_000)).toBe('2.5M');
+ expect(formatCompactNumber(3_000_000_000)).toBe('3B');
+});
diff --git a/web/src/lib/format.ts b/web/src/lib/format.ts
index f54104470..6e0dcb80b 100644
--- a/web/src/lib/format.ts
+++ b/web/src/lib/format.ts
@@ -1,3 +1,9 @@
+// The UI is English-only, so numbers use en-US separators whatever the
+// browser's locale is — a Turkish browser would otherwise show 1,232 as "1.232".
+export function formatNumber(value: number): string {
+ return value.toLocaleString('en-US');
+}
+
export function formatCompactNumber(value: number): string {
const format = (num: number) => num.toFixed(1).replace(/\.0$/, '');
@@ -13,7 +19,7 @@ export function formatCompactNumber(value: number): string {
return `${format(value / 1_000)}k`;
}
- return value.toLocaleString();
+ return formatNumber(value);
}
export function formatDate(iso: string | null): string {