mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
fix(ui): localize JSON-collapse summaries, JSON badge, and Tool sender label (#123325)
jsonSummaryLabel returned hardcoded English ('Object (7 keys)', 'Array (2
items)', 'JSON'), the chat-json-badge span carried a raw 'JSON' literal, and
the tool sender label was a raw 'Tool' string — all rendered on localized
chat surfaces while sibling strings go through t(). #115730's localization
sweep missed these. Raw-copy baseline shrinks by the two badge entries.
This commit is contained in:
committed by
GitHub
parent
c9621adf3e
commit
6000ef2bbe
Generated
-7
@@ -456,13 +456,6 @@
|
||||
"path": "ui/src/pages/channels/view.nostr.ts",
|
||||
"text": "NIP-05"
|
||||
},
|
||||
{
|
||||
"count": 2,
|
||||
"kind": "html-text",
|
||||
"name": "text",
|
||||
"path": "ui/src/pages/chat/components/chat-message-bubble.ts",
|
||||
"text": "JSON"
|
||||
},
|
||||
{
|
||||
"count": 1,
|
||||
"kind": "html-text",
|
||||
|
||||
@@ -4846,6 +4846,10 @@ export const en: TranslationMap = {
|
||||
},
|
||||
codeBlock: {
|
||||
jsonLines: "JSON · {count} lines",
|
||||
jsonBadge: "JSON",
|
||||
jsonArrayItem: "Array ({count} item)",
|
||||
jsonArrayItems: "Array ({count} items)",
|
||||
jsonObjectKeys: "Object ({count} keys)",
|
||||
},
|
||||
workspaceConflict: {
|
||||
titleOne: "1 cloud workspace conflict",
|
||||
@@ -5092,6 +5096,7 @@ export const en: TranslationMap = {
|
||||
showLess: "Show less",
|
||||
showMore: "Show more",
|
||||
unknownDate: "Unknown date",
|
||||
toolSender: "Tool",
|
||||
voiceNote: "Voice note",
|
||||
duplicatesCollapsed: "{count} consecutive identical messages collapsed",
|
||||
contextFor: "Message context for {timestamp}",
|
||||
|
||||
@@ -511,7 +511,7 @@ export function renderGroupedMessage(
|
||||
?open=${Boolean(opts.autoExpandToolCalls)}
|
||||
>
|
||||
<summary class="chat-json-summary">
|
||||
<span class="chat-json-badge">JSON</span>
|
||||
<span class="chat-json-badge">${t("chat.codeBlock.jsonBadge")}</span>
|
||||
<span class="chat-json-label"
|
||||
>${jsonSummaryLabel(jsonResult.parsed)}</span
|
||||
>
|
||||
@@ -575,7 +575,7 @@ export function renderGroupedMessage(
|
||||
${jsonResult
|
||||
? html`<details class="chat-json-collapse">
|
||||
<summary class="chat-json-summary">
|
||||
<span class="chat-json-badge">JSON</span>
|
||||
<span class="chat-json-badge">${t("chat.codeBlock.jsonBadge")}</span>
|
||||
<span class="chat-json-label">${jsonSummaryLabel(jsonResult.parsed)}</span>
|
||||
</summary>
|
||||
<pre class="chat-json-content"><code>${jsonResult.pretty}</code></pre>
|
||||
|
||||
@@ -334,7 +334,7 @@ export function resolveMessageGroupSenderLabel(
|
||||
: normalizedRole === "assistant"
|
||||
? (userLabel ?? assistantName)
|
||||
: normalizedRole === "tool"
|
||||
? "Tool"
|
||||
? t("chat.messages.toolSender")
|
||||
: group.messages.every((item) =>
|
||||
Boolean(workspaceResultConflictFromTranscript(item.message)),
|
||||
)
|
||||
|
||||
@@ -52,16 +52,19 @@ export function detectJson(text: string): { parsed: unknown; pretty: string } |
|
||||
/** Build a short summary label for collapsed JSON (type + key count or array length). */
|
||||
export function jsonSummaryLabel(parsed: unknown): string {
|
||||
if (Array.isArray(parsed)) {
|
||||
return `Array (${parsed.length} item${parsed.length === 1 ? "" : "s"})`;
|
||||
return t(
|
||||
parsed.length === 1 ? "chat.codeBlock.jsonArrayItem" : "chat.codeBlock.jsonArrayItems",
|
||||
{ count: String(parsed.length) },
|
||||
);
|
||||
}
|
||||
if (parsed && typeof parsed === "object") {
|
||||
const keys = Object.keys(parsed as Record<string, unknown>);
|
||||
if (keys.length <= 4) {
|
||||
return `{ ${keys.join(", ")} }`;
|
||||
}
|
||||
return `Object (${keys.length} keys)`;
|
||||
return t("chat.codeBlock.jsonObjectKeys", { count: String(keys.length) });
|
||||
}
|
||||
return "JSON";
|
||||
return t("chat.codeBlock.jsonBadge");
|
||||
}
|
||||
|
||||
export type MessageActionDetails = {
|
||||
|
||||
Reference in New Issue
Block a user