Struggling with DeepL API

536 Views Asked by At

I tried to run the DeepL API but code ends up without a result.

Here's the code I tried:

public void Test()
{
    Console.WriteLine("Starting translation ...................");
    Console.WriteLine(Translation("Hello world!", "DE").Result.Text);
    Console.WriteLine("Translation completed.");
}

public static async Task<DeepL.Model.TextResult> Translation(string text, string targetLanguage)
{
    var authKey = "123456789"
    var translator = new Translator(authKey);
    var translatedText = await translator.TranslateTextAsync(text, null, targetLanguage);
    return translatedText;
}

The first message is shown in the console, but the code ends without the translated text and the translation completed line.

There is no error message.

Can anyone help me?

0

There are 0 best solutions below