pot-app/pot-desktop · error · Error
Language not supported
Error message
Language not supported
What it means
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.
Source
Thrown at src/window/Translate/components/SourceArea/index.jsx:189
detect_language(sourceText).then(() => {
syncSourceText();
});
}
if (event.key === 'Escape') {
appWindow.close();
}
};
const handleSpeak = async () => {
const instanceKey = ttsServiceList[0];
let detected = detectLanguage;
if (detected === '') {
detected = await detect(sourceText);
setDetectLanguage(detected);
}
if (getServiceSouceType(instanceKey) === ServiceSourceType.PLUGIN) {
if (!(detected in ttsPluginInfo.language)) {
throw new Error('Language not supported');
}
const pluginConfig = serviceInstanceConfigMap[instanceKey];
let [func, utils] = await invoke_plugin('tts', getServiceName(instanceKey));
let data = await func(sourceText, ttsPluginInfo.language[detected], {
config: pluginConfig,
utils,
});
speak(data);
} else {
if (!(detected in builtinTtsServices[getServiceName(instanceKey)].Language)) {
throw new Error('Language not supported');
}
const instanceConfig = serviceInstanceConfigMap[instanceKey];
let data = await builtinTtsServices[getServiceName(instanceKey)].tts(
sourceText,
builtinTtsServices[getServiceName(instanceKey)].Language[detected],
{
config: instanceConfig,View on GitHub (pinned to 594d32ede9)
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.
Example fix
// before
if (!(detected in ttsPluginInfo.language)) {
throw new Error('Language not supported');
}
// after
if (!(detected in ttsPluginInfo.language)) {
toast.error(`TTS plugin does not support language: ${detected}`);
return;
} Defensive patterns
Strategy: validation
Validate before calling
const detected = detectedLanguage || await detect(sourceText);
if (getServiceSouceType(instanceKey) === ServiceSourceType.PLUGIN &&
!(detected in ttsPluginInfo.language)) {
// skip TTS or pick another service
return false;
}
return true; Try / catch
try { await handleSpeak(); } catch (e) {
if (e.message === 'Language not supported') {
toast.error('The TTS service does not support the detected language');
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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].
Common situations: 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.
Related errors
AI-assisted analysis of pot-app/pot-desktop@594d32ede9 (2026-09-02).
Data as JSON: /api/errors/2c015e2994933ec9.
Report an issue: GitHub.