TranslationResult
Namespace: Wisej.Ext.Translation
Assembly: Wisej.Ext.Translation (4.1.0.0)
Represents the result of a translation request.
- C#
- VB.NET
public class TranslationResult
Public Class TranslationResult
Constructors
TranslationResult(originalText, translatedText, from, to, errorCode, errorMessage)
Constructs a new instance of TranslationResult.
| Name | Type | Description |
|---|---|---|
| originalText | String | The original text. |
| translatedText | String | The translated text, or null if an error occurred. |
| from | String | The language of the original text. |
| to | String | The language of the translated text. |
| errorCode | Int32 | The error code returned by the translation service, or -1 if the service returned an error message without an error code. Zero if the request was successful. |
| errorMessage | String | The error message returned by the translation service, or null if the request was successful. |
Instances are normally created by a TranslationProviderBase implementation and returned by Translate.
Example:
// Successful translation.
var ok = new TranslationResult("Hello", "Hallo", "en", "de", 0, null);
// Failed translation.
var failed = new TranslationResult("Hello", null, "en", "de", 401, "API key is invalid");
foreach (var result in new[] { ok, failed })
{
if (result.ErrorCode == 0)
Console.WriteLine($"{result.OriginalText} -> {result.TranslatedText}");
else
Console.WriteLine($"Error {result.ErrorCode}: {result.ErrorMessage}");
}
Properties
ErrorCode
Int32: The error code returned by the translation service, or -1 if the service returned an error message without an error code. Zero if the request was successful.
ErrorMessage
String: The error message returned by the translation service, or null if the request was successful.
OriginalLanguage
String: Returns the language of the original text.
OriginalText
String: The original text.
TargetLanguage
String: Returns the language of the translated text.
TranslatedText
String: The translated text, or null if an error occurred.