0

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?

user3840170
  • 26,597
  • 4
  • 30
  • 62
seeker
  • 1
  • I think this is in regard to the asynchronous, so check if Translation("Hello world!", "DE").Result.Text if it has a value property i.e Translation("Hello world!", "DE").Result.Text.Value – Mahmoud Nasr Apr 26 '22 at 11:34
  • I'm facing the same problem... Could you solve the issue? – Adrian Efford Jun 14 '22 at 13:02

0 Answers0