Skip to content

Innacurate source language detection #57

Open
@LuisC360

Description

@LuisC360

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"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions