Создавайте приложения .NET на основе API GroupDocs.Translation, уделяя особое внимание бизнес-логике, а не техническим деталям.
Начать бесплатную пробную версиюGroupDocs.Translation offers real-time machine translation for texts, documents, images, subtitles and resources. Powerful machine learning algorithms and sophisticated neural networks provide a quality close to that of a professional human translator, but much faster and more cost-effective. Running on a high-performance cloud server hosted by GroupDocs, it can translate PDF, Microsoft Office and OpenOffice documents, Markdown files, and .NET resources into 46 European, Middle East and Asian languages (across 128 language pairs). The API not only translates text, but also accurately preserves metadata, structure, styles, and layout of documents.
This SDK greatly simplifies the interaction of .NET code with GroupDocs.Translation Cloud services, allowing you to focus on business logic rather than the technical details. It handles all the routine operations such as establishing connections, sending API requests, and parsing responses, wrapping all these tasks into a few simple methods that can be used in any .NET application. The .NET SDK, demo applications, documentation, and examples are open source distributed under the MIT license. You can use them for any purpose and change any part of the code.
Пакет GroupDocs.Translation Cloud SDK для .NET поставляется с подробными руководствами для разработчиков и живыми примерами кода, позволяющими быстро приступить к работе с функциями API. Просто создайте бесплатную учетную запись в GroupDocs Cloud, получите информацию о SID и ключе приложения для связи с GroupDocs Cloud API, и вы готовы использовать SDK.
GroupDocs.Translation Cloud — это REST API, который легко интегрируется с любым языком или платформой и способен управлять HTTP-запросами и ответами. Он поддерживает все популярные облачные сервисы хранения, такие как Google Cloud, Drive, DropBox и Amazon S3, для взаимодействия без каких-либо зависимостей.
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using GroupDocs.Translation.Cloud.Sdk.Api;
using GroupDocs.Translation.Cloud.Sdk.Client;
using GroupDocs.Translation.Cloud.Sdk.Client.Auth;
using GroupDocs.Translation.Cloud.Sdk.Extensions;
using GroupDocs.Translation.Cloud.Sdk.Model;
using HttpStatusCode = System.Net.HttpStatusCode;
namespace GroupDocs.Translation.Cloud.Sdk
{
public class TextTranslator
{
public TextTranslator()
{
Configuration config = new Configuration();
/** Authorize your requests to GroupDocs.Translation Cloud */
config.OAuthFlow = OAuthFlow.APPLICATION;
config.OAuthClientId = "YOU_CLIENT_ID";
config.OAuthClientSecret = "YOU_CLIENT_SECRET";
/** Initialize GroupDocs.Translation API */
config.BasePath = "https://api.groupdocs.cloud/v2.0/translation";
TranslationApi apiInstance = new TranslationApi(config);
/** Specify translation parameters */
string translateFrom = new List<string>() { "Hello, world! I can read this text in my language." };
string sourceLanguage = "en";
var targetLanguages = new List<string>() { "de" };
var request = new TextRequest(
sourceLanguage: sourceLanguage,
targetLanguages: targetLanguages,
texts: translateFrom);
/** Send text to translation */
StatusResponse translationStatus = apiInstance.TextPost(request);
/** Wait for results from translation queue */
if(translationStatus.Status.ToSystemHttpStatusCode() == HttpStatusCode.Accepted)
{
while(true)
{
var result = apiInstance.TextRequestIdGet(statusResponse.Id);
if(result.Status.ToSystemHttpStatusCode() == HttpStatusCode.OK)
{
Console.WriteLine(result.Translations[toLang].First());
break;
}
Thread.Sleep(1000);
}
}
}
}
}
Облачный API GroupDocs.Translation защищен SSL, а для запросов аутентификации требуется подпись и параметры запроса AppSID или заголовок авторизации OAuth 2.0.