feat(ui): localize UI strings
Converts hardcoded UI copy to i18n keys across the app, adds global translation for non-component modules, and splits the English catalog into feature modules with duplicate-key detection.
This commit is contained in:
@@ -34,6 +34,7 @@ import { createClientSession, mapSdkSessionStatus, type Session, type SessionSta
|
||||
import { sessions, setSessions, syncInstanceSessionIndicator, withSession } from "./session-state"
|
||||
import { normalizeMessagePart } from "./message-v2/normalizers"
|
||||
import { updateSessionInfo } from "./message-v2/session-info"
|
||||
import { tGlobal } from "../lib/i18n"
|
||||
|
||||
import { loadMessages } from "./session-api"
|
||||
import {
|
||||
@@ -308,7 +309,7 @@ function handleSessionUpdate(instanceId: string, event: EventSessionUpdated): vo
|
||||
const newSession = {
|
||||
id: info.id,
|
||||
instanceId,
|
||||
title: info.title || "Untitled",
|
||||
title: info.title || tGlobal("sessionList.session.untitled"),
|
||||
parentId: info.parentID || null,
|
||||
agent: "",
|
||||
model: {
|
||||
@@ -415,10 +416,11 @@ function handleSessionCompacted(instanceId: string, event: EventSessionCompacted
|
||||
const label = session?.title?.trim() ? session.title : sessionID
|
||||
const instanceFolder = instances().get(instanceId)?.folder ?? instanceId
|
||||
const instanceName = instanceFolder.split(/[\\/]/).filter(Boolean).pop() ?? instanceFolder
|
||||
const displayLabel = label ? `"${label}"` : sessionID
|
||||
|
||||
showToastNotification({
|
||||
title: instanceName,
|
||||
message: `Session ${label ? `"${label}"` : sessionID} was compacted`,
|
||||
message: tGlobal("sessionEvents.sessionCompactedToast", { label: displayLabel }),
|
||||
variant: "info",
|
||||
duration: 10000,
|
||||
})
|
||||
@@ -428,7 +430,7 @@ function handleSessionError(_instanceId: string, event: EventSessionError): void
|
||||
const error = event.properties?.error
|
||||
log.error(`[SSE] Session error:`, error)
|
||||
|
||||
let message = "Unknown error"
|
||||
let message = tGlobal("sessionEvents.sessionError.unknown")
|
||||
|
||||
if (error) {
|
||||
if ("data" in error && error.data && typeof error.data === "object" && "message" in error.data) {
|
||||
@@ -438,8 +440,8 @@ function handleSessionError(_instanceId: string, event: EventSessionError): void
|
||||
}
|
||||
}
|
||||
|
||||
showAlertDialog(`Error: ${message}`, {
|
||||
title: "Session error",
|
||||
showAlertDialog(tGlobal("sessionEvents.sessionError.message", { message }), {
|
||||
title: tGlobal("sessionEvents.sessionError.title"),
|
||||
variant: "error",
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user