mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-11-01 10:22:08 +00:00
i18n: localize optimization source viewer and protect pending reads
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
type Translate = (key: string, params?: Record<string, string | number>) => string
|
||||
|
||||
export interface OptimizationSourceError {
|
||||
kind: "unavailable" | "loadFailed"
|
||||
detail?: string
|
||||
}
|
||||
|
||||
// Keep the blueprint's English API contract intact; translate only its display.
|
||||
export function optimizationSourceError(error: OptimizationSourceError, t: Translate): string {
|
||||
const detail = error.detail || ""
|
||||
const key = "settings.optimizations."
|
||||
if (detail === "Function not found in available scripts") return t(key + "sourceFunctionMissing")
|
||||
if (detail.startsWith("Unknown tool: ")) return t(key + "sourceUnknownTool", { tool: detail.slice(14) })
|
||||
if (detail.startsWith("No function mapping for ")) return t(key + "sourceNoMapping", { tool: detail.slice(24) })
|
||||
if (detail === "Source code not available") return t(key + "sourceUnavailable")
|
||||
const message = t(key + (error.kind === "unavailable" ? "sourceUnavailable" : "sourceLoadFailed"))
|
||||
return detail ? `${message} ${detail}` : message
|
||||
}
|
||||
Reference in New Issue
Block a user