Open
Description
I don't know why this happens, but when I try to get the source language of a small snippet of text, it always gives me an innacurate source language code.
To Reproduce
const { Translator } = require('deepl-node');
const apiKey = process.env.DEEPL_API_KEY;
const translator = apiKey ? new Translator(apiKey) : null;
// Assume text === "Paso uno", source language is Spanish ('es')
async function getSourceLanguage(text) {
if (!translator) {
return 'en';
}
try {
const translation = await translator.translateText(text, null, target_lang='EN-GB');
return translation.detectedSourceLang; // Got Italian ('it') as the detected source language
} catch (error) {
console.error('DeepL API error: ', error);
}
}
Expected behavior
The function should return 'es'
for the assumed input
Additional context
Library version "^1.14.0"
Metadata
Metadata
Assignees
Labels
No labels
Activity