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.
27 lines
1.3 KiB
TypeScript
27 lines
1.3 KiB
TypeScript
import type { ToolRenderer } from "../types"
|
|
import { ensureMarkdownContent, getRelativePath, getToolName, inferLanguageFromPath, readToolStatePayload } from "../utils"
|
|
import { tGlobal } from "../../../lib/i18n"
|
|
|
|
export const writeRenderer: ToolRenderer = {
|
|
tools: ["write"],
|
|
getAction: () => tGlobal("toolCall.renderer.action.preparingWrite"),
|
|
getTitle({ toolState }) {
|
|
const state = toolState()
|
|
if (!state) return undefined
|
|
const { input } = readToolStatePayload(state)
|
|
const filePath = typeof input.filePath === "string" ? input.filePath : ""
|
|
if (!filePath) return getToolName("write")
|
|
return `${getToolName("write")} ${getRelativePath(filePath)}`
|
|
},
|
|
renderBody({ toolState, renderMarkdown }) {
|
|
const state = toolState()
|
|
if (!state || state.status === "pending") return null
|
|
const { metadata, input } = readToolStatePayload(state)
|
|
const contentValue = typeof input.content === "string" ? input.content : metadata.content
|
|
const filePath = typeof input.filePath === "string" ? input.filePath : undefined
|
|
const content = ensureMarkdownContent(contentValue ?? null, inferLanguageFromPath(filePath), true)
|
|
if (!content) return null
|
|
return renderMarkdown({ content, size: "large", disableHighlight: state.status === "running" })
|
|
},
|
|
}
|