Yandex.Translate 1.0.1

dotnet add package Yandex.Translate --version 1.0.1                
NuGet\Install-Package Yandex.Translate -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Yandex.Translate" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Yandex.Translate --version 1.0.1                
#r "nuget: Yandex.Translate, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Yandex.Translate as a Cake Addin
#addin nuget:?package=Yandex.Translate&version=1.0.1

// Install Yandex.Translate as a Cake Tool
#tool nuget:?package=Yandex.Translate&version=1.0.1                

Yandex.Translate Client

This is a simple client for the Yandex.Translate service.

Core Features

All core features share the same client class TranslateClient. To start using it simply create a new instance of the class:

  1. At first, create configuration object (for now it contains API key property only)
  2. Then simply create TranslateClient instance.
var config = new TranslateClientConfiguration("YOUR_API_KEY");
var client = new TranslateClient(config);

Translation

To translate text you can use TranslateClient.TranslateAsync(text, sourceLang, targetLang, format = text) method which returns Translation object that contains possible translations and some additional metadata like source string, source and target language codes and format.

var translation = await client.TranslateAsync("Hellow World!", "en", "ru");
Console.WriteLine(translation.First()!) // Output: "Привет, мир!"

TranslateClient.TranslateAsync Accepts the following arguments:

  1. Text to be translated (string);
  2. Source language code (string);
  3. Target language code (string);
  4. Translate format, which specifies whether text to be translated is a plain text or HTML (TextFormat enum).

Language Detection

To detect language you can use TranslateClient.DetectLanguageAsync(text, hintLanguages) method which returns detected language code.

var detectedLanguage = await client.DetectLanguageAsync("Hello World!");
Console.WriteLine(detectedLanguage) // Output: "en"

DetectLanguageAsync accepts the following parameters:

  1. Text which is used as reference for language detection (string);
  2. Hint languages. When detecting language, hint language will be preferred (IEnumerable<string>).

Supported Languages

To get supported languages you can use the TranslateClient.GetSupportedLanguages(displayLanguageCode = "en") method:

var supportedLanguagesData = await client.GetSupportedLanguages();
foreach(var language in supportedLanguagesData.Languages) {
    Console.WriteLine(language.Code) // Output: "en", "ru", "pt"
    Console.WriteLine(language.Name) // Output: "English", "Russian", "Protugeese".
}
foreach(var direction in supportedLanguagesData.Directions) {
    Console.WriteLine(direction.SourceLanguage) // Output: "en", "en", "en"
    Console.WriteLine(direction.TargetLanguage) // Output: "ru", "pt", "es"
}

GetSupportedLanguages accepts displayLanguageCode which specifies which language will be used to display language names.

The method returns SupportedLanguagesData object which contains supported languages and supported directions.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Yandex.Translate:

Package Downloads
Yandex.Translate.Extensions.DependencyInjection

Dependency Injection extensions for for the Yandex.Translate package.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 582 7/1/2022 1.0.1 is deprecated because it is no longer maintained.
1.0.0 397 7/1/2022