Exemplo n.º 1
0
 private static void TestTranslation(ITranslationProvider provider, CultureInfo src, CultureInfo tgt)
 {
     if (provider.IsSupported(src, tgt))
     {
         provider.Initialize(src, tgt, null);
         var response = provider.Translate(new TranslationRequest {
             RequestId = "1", Source = "The dog is blue.", MinimumConfidence = 50
         });
         Console.WriteLine($"Translate from {src} to {tgt}");
         Console.WriteLine($"   {response.Source}");
         if (response.IsTranslated)
         {
             Console.WriteLine($"   {response.Target}");
         }
         else
         {
             foreach (var error in response?.Errors)
             {
                 Console.WriteLine($"   {error.Message}");
             }
         }
         var suggestions = provider.Suggest(new SuggestionRequest  {
             RequestId = "1", Source = "The dog is blue.", MinimumConfidence = 50
         });
     }
 }