Skip to content

Commit 3eb596b

Browse files
committed
fix(embeddings): translate error messages before sending to UI
- Import t() function from i18n module - Wrap error messages with t() translation function in _initializeEmbedder() - Ensures proper localization of error messages in the UI - Falls back to original message if no translation exists
1 parent 5f08607 commit 3eb596b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/services/code-index/manager.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { CacheManager } from "./cache-manager"
1212
import fs from "fs/promises"
1313
import ignore from "ignore"
1414
import path from "path"
15+
import { t } from "../../i18n"
1516

1617
export class CodeIndexManager {
1718
// --- Singleton Implementation ---
@@ -261,12 +262,16 @@ export class CodeIndexManager {
261262
// Validate embedder configuration before proceeding
262263
const validationResult = await this._serviceFactory.validateEmbedder(embedder)
263264
if (!validationResult.valid) {
264-
// Set error state with clear message
265-
this._stateManager.setSystemState(
266-
"Error",
267-
validationResult.error || "Embedder configuration validation failed",
268-
)
269-
throw new Error(validationResult.error || "Invalid embedder configuration")
265+
const errorMessage = validationResult.error || "Embedder configuration validation failed"
266+
// Always attempt translation, use original as fallback
267+
let translatedMessage = t(errorMessage)
268+
// If translation returns a different value (stripped namespace), use original
269+
if (translatedMessage !== errorMessage && !translatedMessage.includes(":")) {
270+
translatedMessage = errorMessage
271+
}
272+
273+
this._stateManager.setSystemState("Error", translatedMessage)
274+
throw new Error(translatedMessage)
270275
}
271276

272277
// (Re)Initialize orchestrator

0 commit comments

Comments
 (0)