Tilde.Translation 1.1.0.86

dotnet add package Tilde.Translation --version 1.1.0.86                
NuGet\Install-Package Tilde.Translation -Version 1.1.0.86                
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="Tilde.Translation" Version="1.1.0.86" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tilde.Translation --version 1.1.0.86                
#r "nuget: Tilde.Translation, 1.1.0.86"                
#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 Tilde.Translation as a Cake Addin
#addin nuget:?package=Tilde.Translation&version=1.1.0.86

// Install Tilde.Translation as a Cake Tool
#tool nuget:?package=Tilde.Translation&version=1.1.0.86                

Tilde translation .NET library

Tilde MT is a translation platform for instant, fluent, and secure text, document translation.

This .NET library provides a robust and user-friendly interface for integrating machine translation capabilities into your .NET applications. Powered by advanced neural machine translation models, it enables seamless translation of text between multiple languages.

Installation

Using the .NET Core command-line interface (CLI) tools:

dotnet add package Tilde.Translation

Using the NuGet Command Line Interface (CLI):

nuget install Tilde.Translation

Supported frameworks

  • .NET Standard 2.0
  • .NET 6.0

Usage

Initialize Translator using Access key (API key).

using Tilde.Translation;
using Tilde.Translation.Exceptions;

var apiKey = "00000000-0000-0000-0000-000000000000"; 
var translator = new Translator(apiKey);

When implementing this library in your application, please provide information about application where this library will be used. This is optional step, but recomended

var options = new TranslatorOptions()
{
    AppInfo = new AppInfo()
    {
        AppName = "my-app",
        AppVersion = "1.0.0",
    }
};
var translator = new Translator(apiKey, options);

Translating text

var translation = await translator.TranslateTextAsync("First sentence", "en", "lv");

Console.WriteLine(translation.DetectedLanguage); // null | "en" | ...
Console.WriteLine(translation.Domain); // "finance"
Console.WriteLine(translation.Translations[0].Translation); // "Pirmais teikums"

Translating documents

// Specify file to translate 
var sourceDocument = new FileInfo(@"./Document/ExampleDocument.txt");

// Start document translation
var documentHandle = await translator.TranslateDocumentAsync(sourceDocument, "en", "lv");

// Wait for document translation to finish
var documentStatus = await translator.TranslateDocumentWaitUntilDoneAsync(documentHandle);

Console.WriteLine(documentStatus.Status); // Completed
Console.WriteLine(documentStatus.Substatus); // Unspecified

// Save file 
var fileStream = File.Create(@"./Document/ExampleDocumentResult.txt");
await translator.TranslateDocumentResultAsync(documentHandle, fileStream);
fileStream.Close();

Get available engines

var engines = await translator.GetEnginesAsync();

Console.WriteLine(engines.First().SourceLanguages.First()); // "en"
Console.WriteLine(engines.First().TargetLanguages.First()); // "lv"

Get available language directions

This is similar to available engines, but engines are grouped by source language, target language and domain

await foreach (var languageDirection in translator.GetLanguageDirections())
{
    var srcLang = languageDirection.SourceLanguage;
    var trgLang = languageDirection.TargetLanguage;
    var domain = languageDirection.Domain;
    var engineId = languageDirection.EngineId;
    var engineName = languageDirection.EngineName;

    Console.WriteLine($"{srcLang} -> {trgLang} [{domain}] | {engineId} ({engineName})");
}

Error handling

All errors are derived from TildeException base exception. To catch errors use TildeException or derived specific exceptions.

try
{
    var translation = await translator.TranslateTextAsync("First sentence", "en", "lv");

    Console.WriteLine(translation.DetectedLanguage);
    Console.WriteLine(translation.Domain);
    Console.WriteLine(translation.Translations[0].Translation);
}
catch (TildeException ex)
{
    Console.WriteLine(ex.Message);
}

Contributing

We welcome contributions from the community! If you encounter issues, have suggestions, or want to add new features, please submit a pull request or open an issue on the GitHub repository.

License

This library is licensed under the MIT License, allowing flexibility for both personal and commercial use.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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 is compatible.  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 is compatible.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  net481 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0.86 220 9/10/2024
1.1.0.85 154 8/23/2024
1.1.0.84 119 8/23/2024
1.0.11.83 116 8/21/2024
1.0.10.82 119 8/9/2024
1.0.10.81 82 8/1/2024
1.0.10.80 92 8/1/2024
1.0.10.79 84 7/31/2024
1.0.10.78 74 7/31/2024
1.0.9 74 7/31/2024
1.0.8 77 7/31/2024