Lyo.Translation 2.0.0

dotnet add package Lyo.Translation --version 2.0.0
                    
NuGet\Install-Package Lyo.Translation -Version 2.0.0
                    
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="Lyo.Translation" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lyo.Translation" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Lyo.Translation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Lyo.Translation --version 2.0.0
                    
#r "nuget: Lyo.Translation, 2.0.0"
                    
#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.
#:package Lyo.Translation@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Lyo.Translation&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Lyo.Translation&version=2.0.0
                    
Install as a Cake Tool

Lyo.Translation

Archetype B (capability). Providers (Lyo.Translation.Google, Lyo.Translation.Aws) remain under Communication/Translation/, not Integration/. See package layout.

Contracts and shared translation behavior: ITranslationService, TranslationServiceBase (bulk pipeline, metrics, lifecycle events), error codes, metric key names, and a small DI helper.

Target frameworks: netstandard2.0;net10.0

Examples

Injection helpers

services.AddTranslationService<MyTranslationService, MyTranslationOptions>(opts =>
{
    opts.DefaultSourceLanguage = LanguageCodeInfo.EnUs;
});

// or with a pre-built options instance:
services.AddTranslationService<MyTranslationService, MyTranslationOptions>(myOptions);

ITranslationService

Member Description
TranslateAsync(string text, LanguageCodeInfo targetLanguageCode, LanguageCodeInfo? sourceLanguage = null, CancellationToken ct = default) Convenience overload. Builds a TranslationRequest and applies Options.DefaultSourceLanguage when the caller leaves source unset.
TranslateAsync(TranslationRequest request, CancellationToken ct = default) Translates one TranslationRequest.
TranslateBulkAsync(IEnumerable<TranslationRequest> requests, CancellationToken ct = default) Bulk send capped by concurrency. Returns IReadOnlyList<TranslationResult>.
DetectLanguageAsync(string text, CancellationToken ct = default) Detects the language of text and returns LanguageCodeInfo. Providers may return unknown info on failure.
TestConnectionAsync(CancellationToken ct = default) Provider-defined connectivity check.

TranslationServiceBase

  • Shared bulk pipeline using a SemaphoreSlim sized by TranslationServiceOptions.BulkTranslationConcurrencyLimit and a hard per-call cap of TranslationServiceOptions.MaxBulkTranslationLimit.
  • Bulk results land in a ConcurrentBag, so output order is not guaranteed to match input order.
  • Lifecycle events: Translating, Translated, BulkTranslating, BulkTranslated.
  • A MetricNames dictionary that providers may override in the constructor.

TranslationServiceOptions

Property Type Default Purpose
DefaultTargetLanguage LanguageCodeInfo? null Provider fallback used when the caller omits a target.
DefaultSourceLanguage LanguageCodeInfo? null Source language used when callers leave it unset.
MaxTextLength int 50000 Upper bound on text length providers should accept.
EnableMetrics bool true When false, the base substitutes NullMetrics.Instance.
BulkTranslationConcurrencyLimit int 10 Cap on bulk dispatch concurrency.
MaxBulkTranslationLimit int 100 Upper bound on requests in one TranslateBulkAsync call.

Failure codes (TranslationErrorCodes)

Constant Value
TranslateFailed TRANSLATION_FAILED
OperationCancelled TRANSLATION_OPERATION_CANCELLED
DetectLanguageFailed TRANSLATION_DETECT_LANGUAGE_FAILED

Default metric keys (Lyo.Translation.Constants.Metrics)

Constant key Metric Kind
TranslateDuration translation.Service.translate.duration Timer
TranslateSuccess translation.Service.translate.success Counter
TranslateFailure translation.Service.translate.failure Counter
BulkTranslateDuration translation.Service.bulk.translate.duration Timer
BulkTranslateTotal translation.Service.bulk.translate.total Counter
BulkTranslateSuccess translation.Service.bulk.translate.success Counter
BulkTranslateFailure translation.Service.bulk.translate.failure Counter
BulkTranslateLastDurationMs translation.Service.bulk.translate.last_duration_ms Gauge
DetectLanguageDuration translation.Service.detectLanguage.duration Timer
DetectLanguageSuccess translation.Service.detectLanguage.success Counter
DetectLanguageFailure translation.Service.detectLanguage.failure Counter

Provider packages (Google, AWS) override CreateMetricNamesDictionary to put a namespace on these.

Injection helpers

Lyo.Translation.Extensions exposes a generic helper used by provider packages. It wires TOptions, TService, and ITranslationService (resolved from TService) as singletons. Concrete provider packages (Lyo.Translation.Google, Lyo.Translation.Aws) wrap this in their own Add*FromConfiguration extensions that also wire native SDK clients.

Dependencies

Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).

  • Lyo.Common.Metadata (direct, lyo)
  • Lyo.Exceptions (direct, lyo)
  • Lyo.Metrics (direct, lyo)
  • Lyo.Result (direct, lyo)
  • Microsoft.Extensions.DependencyInjection.Abstractions 10.0.5 (direct, microsoft)
  • Microsoft.Extensions.Logging.Abstractions 10.0.5 (direct, microsoft)
  • Lyo.Common.Core (transitive, lyo)
  • Microsoft.Bcl.AsyncInterfaces 10.0.5 (transitive, microsoft, netstandard2.0)
  • System.Memory 4.6.3 (transitive, microsoft, netstandard2.0)
  • System.Text.Json 10.0.5 (transitive, microsoft, netstandard2.0)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
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 (3)

Showing the top 3 NuGet packages that depend on Lyo.Translation:

Package Downloads
Lyo.Translation.Google

Google Translate implementation for the Lyo translation service.

Lyo.Translation.Aws

AWS Translate implementation for the Lyo translation service.

Lyo.Translation.Web.Components

Reusable Blazor components for provider-neutral translation workbenches.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 203 9/9/2026
1.0.13 175 8/25/2026
1.0.11 159 8/23/2026
1.0.9 182 8/22/2026
1.0.6 171 8/20/2026
1.0.4 184 8/20/2026
1.0.3 171 8/19/2026
1.0.2 173 8/19/2026
1.0.1 180 8/18/2026
1.0.0 180 8/16/2026