Add initial check before throwing error below

pull/1214/head
Lim Chee Aun 2025-07-12 15:21:41 +08:00
rodzic d561e67534
commit e416b853c9
1 zmienionych plików z 5 dodań i 0 usunięć

Wyświetl plik

@ -37,6 +37,11 @@ export const translate = async (text, source, target) => {
let detectedSourceLanguage;
const originalSource = source;
if (source === 'auto') {
if (!langDetector?.detect) {
return {
error: 'No language detector',
};
}
try {
const results = await langDetector.detect(text);
source = results[0].detectedLanguage;