{"record":{"id":"2c015e2994933ec9","repo":"pot-app/pot-desktop","slug":"language-not-supported","errorCode":null,"errorMessage":"Language not supported","messagePattern":"Language not supported","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/window/Translate/components/SourceArea/index.jsx","lineNumber":189,"sourceCode":"            detect_language(sourceText).then(() => {\n                syncSourceText();\n            });\n        }\n        if (event.key === 'Escape') {\n            appWindow.close();\n        }\n    };\n\n    const handleSpeak = async () => {\n        const instanceKey = ttsServiceList[0];\n        let detected = detectLanguage;\n        if (detected === '') {\n            detected = await detect(sourceText);\n            setDetectLanguage(detected);\n        }\n        if (getServiceSouceType(instanceKey) === ServiceSourceType.PLUGIN) {\n            if (!(detected in ttsPluginInfo.language)) {\n                throw new Error('Language not supported');\n            }\n            const pluginConfig = serviceInstanceConfigMap[instanceKey];\n            let [func, utils] = await invoke_plugin('tts', getServiceName(instanceKey));\n            let data = await func(sourceText, ttsPluginInfo.language[detected], {\n                config: pluginConfig,\n                utils,\n            });\n            speak(data);\n        } else {\n            if (!(detected in builtinTtsServices[getServiceName(instanceKey)].Language)) {\n                throw new Error('Language not supported');\n            }\n            const instanceConfig = serviceInstanceConfigMap[instanceKey];\n            let data = await builtinTtsServices[getServiceName(instanceKey)].tts(\n                sourceText,\n                builtinTtsServices[getServiceName(instanceKey)].Language[detected],\n                {\n                    config: instanceConfig,","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/pot-app/pot-desktop/blob/594d32ede96acd106b0256deaa8bb440ffcdff40/src/window/Translate/components/SourceArea/index.jsx#L171-L207","documentation":"handleSpeak in the Translate window's SourceArea throws this plain Error when the auto-detected source language is not a key in the selected TTS plugin's language map (ttsPluginInfo.language). The plugin only exposes TTS voices for the languages listed in that map, so any detected code outside it (e.g. auto-detected 'zh-CN' when the plugin only registers 'zh') cannot be spoken. It is an application-level guard, thrown before invoke_plugin is called.","triggerScenarios":"User clicks speak on the source text while the active TTS service is a PLUGIN-type instance; detected (auto-detected via detect() or previously cached via setDetectLanguage) is '' -missing- or not a key of ttsPluginInfo.language[serviceName].","commonSituations":"Auto language detection returns a code variant the plugin doesn't declare (e.g. 'zh-TW' vs 'zh', 'en-GB' vs 'en'); the TTS plugin simply lacks support for that language; a stale cached detected value no longer matches plugin config after the plugin was updated/reconfigured.","solutions":["Switch to a TTS service (plugin or builtin) that supports the detected language, in Preferences > Service Config > TTS.","Check the plugin's supported language list and update the plugin to a version that registers the detected language code.","Set the source language manually instead of auto-detect so the detected code matches a key in ttsPluginInfo.language.","Catch the error in handleSpeak and surface a friendly notification instead of an unhandled rejection."],"exampleFix":"// before\nif (!(detected in ttsPluginInfo.language)) {\n    throw new Error('Language not supported');\n}\n// after\nif (!(detected in ttsPluginInfo.language)) {\n    toast.error(`TTS plugin does not support language: ${detected}`);\n    return;\n}","handlingStrategy":"validation","validationCode":"const detected = detectedLanguage || await detect(sourceText);\nif (getServiceSouceType(instanceKey) === ServiceSourceType.PLUGIN &&\n    !(detected in ttsPluginInfo.language)) {\n  // skip TTS or pick another service\n  return false;\n}\nreturn true;","typeGuard":null,"tryCatchPattern":"try { await handleSpeak(); } catch (e) {\n  if (e.message === 'Language not supported') {\n    toast.error('The TTS service does not support the detected language');\n  } else throw e;\n}","preventionTips":["Check ttsPluginInfo.language keys before enabling the speak button.","Avoid stale cached detected-language state; re-detect when text changes.","Prefer a TTS service whose language coverage matches your translation services."],"tags":["tts","plugin","language-detection","unsupported-language"],"backgroundTag":"tts-language-not-supported","analyzedSha":"594d32ede96acd106b0256deaa8bb440ffcdff40","analyzedAt":"2026-09-02T18:12:21.811Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}