Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/ca/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "mil",
"million_suffix": "M",
"billion_suffix": "MM"
}
}
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/de/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "Tsd.",
"million_suffix": "Mio.",
"billion_suffix": "Mrd."
}
}
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/en/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "k",
"million_suffix": "m",
"billion_suffix": "b"
}
}
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/es/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "k",
"million_suffix": "M",
"billion_suffix": "MM"
}
}
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/fr/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "k",
"million_suffix": "M",
"billion_suffix": "Md"
}
}
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/hi/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "ह",
"million_suffix": "लाख",
"billion_suffix": "अरब"
}
}
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/it/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "k",
"million_suffix": "Mln",
"billion_suffix": "Mld"
}
}
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/ja/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "k",
"million_suffix": "M",
"billion_suffix": "B"
}
}
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/ko/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "천",
"million_suffix": "백만",
"billion_suffix": "십억"
}
}
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/pl/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "tys.",
"million_suffix": "mln",
"billion_suffix": "mld"
}
}
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/pt-BR/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "mil",
"million_suffix": "mi",
"billion_suffix": "bi"
}
}
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/tr/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "B",
"million_suffix": "Mn",
"billion_suffix": "Mr"
}
}
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/vi/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "k",
"million_suffix": "tr",
"billion_suffix": "tỷ"
}
}
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/zh-CN/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "千",
"million_suffix": "百万",
"billion_suffix": "十亿"
}
}
8 changes: 7 additions & 1 deletion webview-ui/src/i18n/locales/zh-TW/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"number_format": {
"thousand_suffix": "千",
"million_suffix": "百萬",
"billion_suffix": "十億"
}
}
36 changes: 22 additions & 14 deletions webview-ui/src/utils/format.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
import i18next from "i18next"

export function formatLargeNumber(num: number): string {
if (num >= 1e9) {
return (num / 1e9).toFixed(1) + "b"
return (num / 1e9).toFixed(1) + i18next.t("common:number_format.billion_suffix")
}
if (num >= 1e6) {
return (num / 1e6).toFixed(1) + "m"
return (num / 1e6).toFixed(1) + i18next.t("common:number_format.million_suffix")
}
if (num >= 1e3) {
return (num / 1e3).toFixed(1) + "k"
return (num / 1e3).toFixed(1) + i18next.t("common:number_format.thousand_suffix")
}
return num.toString()
}

export const formatDate = (timestamp: number) => {
const date = new Date(timestamp)
return date
.toLocaleString("en-US", {
month: "long",
day: "numeric",
hour: "numeric",
minute: "2-digit",
hour12: true,
})
.replace(", ", " ")
.replace(" at", ",")
.toUpperCase()
const locale = i18next.language || "en"

// Get date format style from translations or use default transformations
const dateStr = date.toLocaleString(locale, {
month: "long",
day: "numeric",
hour: "numeric",
minute: "2-digit",
hour12: true,
})

// Apply transformations based on locale or use default
if (locale === "en") {
return dateStr.replace(", ", " ").replace(" at", ",").toUpperCase()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a more robust date formatting library (like date-fns or moment) to avoid manual string replacements in formatDate(). This manual replacement may not cover all locale-specific nuances.

}

return dateStr.toUpperCase()
}
Loading