kopia lustrzana https://github.com/cheeaun/phanpy
Add initial check before throwing error below
rodzic
d561e67534
commit
e416b853c9
|
@ -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;
|
||||
|
|
Ładowanie…
Reference in New Issue