fix: Format view count correctly on shared links table

This commit is contained in:
Tom Moor
2024-04-16 21:06:18 -04:00
parent 780c3f8f04
commit 1f6d8f8471
2 changed files with 27 additions and 3 deletions

View File

@@ -2,6 +2,21 @@ import { i18n } from "i18next";
import { unicodeCLDRtoBCP47 } from "@shared/utils/date";
import Desktop from "./Desktop";
/**
* Formats a number using the user's locale where possible.
*
* @param number The number to format
* @param locale The locale to use for formatting (BCP47 format)
* @returns The formatted number as a string
*/
export function formatNumber(number: number, locale: string) {
try {
return new Intl.NumberFormat(locale).format(number);
} catch (e) {
return number.toString();
}
}
/**
* Detects the user's language based on the browser's language settings.
*