Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
f4575fe6
authored
Jun 18, 2026
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(format): add locales support to number formatting
parent
cfc9bbcd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
web/default/src/features/dashboard/components/models/log-stat-cards.tsx
+7
-4
web/default/src/lib/format.ts
+10
-4
No files found.
web/default/src/features/dashboard/components/models/log-stat-cards.tsx
View file @
f4575fe6
...
...
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import
{
useEffect
,
useState
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
{
useAuthStore
}
from
'@/stores/auth-store'
import
{
formatCompactNumber
,
formatNumber
,
formatQuota
}
from
'@/lib/format'
import
{
computeTimeRange
}
from
'@/lib/time'
...
...
@@ -41,11 +42,11 @@ interface LogStatCardsProps {
const
MAX_INLINE_STAT_CHARS
=
9
function
formatStatNumber
(
value
:
number
)
{
const
fullValue
=
formatNumber
(
value
)
function
formatStatNumber
(
value
:
number
,
locale
:
Intl
.
LocalesArgument
)
{
const
fullValue
=
formatNumber
(
value
,
locale
)
const
displayValue
=
fullValue
.
length
>
MAX_INLINE_STAT_CHARS
?
formatCompactNumber
(
value
)
?
formatCompactNumber
(
value
,
locale
)
:
fullValue
return
{
...
...
@@ -55,6 +56,7 @@ function formatStatNumber(value: number) {
}
export
function
LogStatCards
(
props
:
LogStatCardsProps
)
{
const
{
i18n
}
=
useTranslation
()
const
statCardsConfig
=
useModelStatCardsConfig
()
const
user
=
useAuthStore
((
state
)
=>
state
.
auth
.
user
)
const
isAdmin
=
!!
(
user
?.
role
&&
user
.
role
>=
10
)
...
...
@@ -118,13 +120,14 @@ export function LogStatCards(props: LogStatCardsProps) {
const
items
=
statCardsConfig
.
map
((
config
)
=>
{
const
rawValue
=
config
.
getValue
(
adaptedStats
,
timeRangeMinutes
)
const
locale
=
i18n
.
resolvedLanguage
||
i18n
.
language
const
formatted
=
config
.
key
===
'quota'
?
{
displayValue
:
formatQuota
(
rawValue
),
fullValue
:
formatQuota
(
rawValue
),
}
:
formatStatNumber
(
rawValue
)
:
formatStatNumber
(
rawValue
,
locale
)
return
{
title
:
config
.
title
,
...
...
web/default/src/lib/format.ts
View file @
f4575fe6
...
...
@@ -27,16 +27,22 @@ import {
// Number Formatting
// ============================================================================
export
function
formatNumber
(
value
:
number
|
null
|
undefined
):
string
{
export
function
formatNumber
(
value
:
number
|
null
|
undefined
,
locales
?:
Intl
.
LocalesArgument
):
string
{
if
(
value
==
null
||
Number
.
isNaN
(
value
as
number
))
return
'-'
return
Intl
.
NumberFormat
(
undefined
,
{
maximumFractionDigits
:
2
}).
format
(
return
Intl
.
NumberFormat
(
locales
,
{
maximumFractionDigits
:
2
}).
format
(
value
as
number
)
}
export
function
formatCompactNumber
(
value
:
number
|
null
|
undefined
):
string
{
export
function
formatCompactNumber
(
value
:
number
|
null
|
undefined
,
locales
?:
Intl
.
LocalesArgument
):
string
{
if
(
value
==
null
||
Number
.
isNaN
(
value
as
number
))
return
'-'
return
Intl
.
NumberFormat
(
undefined
,
{
return
Intl
.
NumberFormat
(
locales
,
{
notation
:
'compact'
,
maximumFractionDigits
:
1
,
}).
format
(
value
as
number
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment