fix(android): localize compact token suffixes

This commit is contained in:
Vincent Koc
2026-07-21 14:15:59 +02:00
parent 8283e976ed
commit 85ba26ebad
2 changed files with 15 additions and 9 deletions
+7 -7
View File
@@ -13011,7 +13011,7 @@
},
{
"kind": "ui-call",
"line": 222,
"line": 223,
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/chat/ChatTurnRecap.kt",
"source": "1 token",
"surface": "android",
@@ -13019,7 +13019,7 @@
},
{
"kind": "ui-call",
"line": 224,
"line": 225,
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/chat/ChatTurnRecap.kt",
"source": "$count tokens",
"surface": "android",
@@ -13027,23 +13027,23 @@
},
{
"kind": "ui-call",
"line": 234,
"line": 235,
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/chat/ChatTurnRecap.kt",
"source": "Done in $duration",
"surface": "android",
"id": "native.android.c32ff602fa622e4b"
},
{
"kind": "conditional-branch",
"line": 253,
"kind": "ui-call",
"line": 252,
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/chat/ChatTurnRecap.kt",
"source": "${decimal(count / 1_000_000.0)}M",
"surface": "android",
"id": "native.android.d2797e7488fe5021"
},
{
"kind": "conditional-branch",
"line": 253,
"kind": "ui-call",
"line": 259,
"path": "apps/android/app/src/main/java/ai/openclaw/app/ui/chat/ChatTurnRecap.kt",
"source": "${thousands}k",
"surface": "android",
@@ -1,6 +1,7 @@
package ai.openclaw.app.ui.chat
import ai.openclaw.app.chat.ChatSessionEntry
import ai.openclaw.app.i18n.nativeString
import ai.openclaw.app.i18n.nativeStringResource
import ai.openclaw.app.ui.design.ClawTheme
import androidx.compose.foundation.layout.Arrangement
@@ -246,11 +247,16 @@ internal fun turnRecapTokenFormat(count: Long): TurnRecapTokenFormat = TurnRecap
internal fun formatCompactTokenCount(count: Long): String {
fun decimal(value: Double): String = String.format(Locale.US, "%.1f", value).removeSuffix(".0")
fun millions(): String {
val value = decimal(count / 1_000_000.0)
return nativeString("\${decimal(count / 1_000_000.0)}M", value)
}
return when {
count >= 1_000_000L -> "${decimal(count / 1_000_000.0)}M"
count >= 1_000_000L -> millions()
count >= 1_000L -> {
val thousands = decimal(count / 1_000.0)
if (thousands == "1000") "${decimal(count / 1_000_000.0)}M" else "${thousands}k"
if (thousands == "1000") millions() else nativeString("\${thousands}k", thousands)
}
else -> count.toString()
}