Lyo.Translation
2.0.0
dotnet add package Lyo.Translation --version 2.0.0
NuGet\Install-Package Lyo.Translation -Version 2.0.0
<PackageReference Include="Lyo.Translation" Version="2.0.0" />
<PackageVersion Include="Lyo.Translation" Version="2.0.0" />
<PackageReference Include="Lyo.Translation" />
paket add Lyo.Translation --version 2.0.0
#r "nuget: Lyo.Translation, 2.0.0"
#:package Lyo.Translation@2.0.0
#addin nuget:?package=Lyo.Translation&version=2.0.0
#tool nuget:?package=Lyo.Translation&version=2.0.0
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
SemaphoreSlimsized byTranslationServiceOptions.BulkTranslationConcurrencyLimitand a hard per-call cap ofTranslationServiceOptions.MaxBulkTranslationLimit. - Bulk results land in a
ConcurrentBag, so output order is not guaranteed to match input order. - Lifecycle events:
Translating,Translated,BulkTranslating,BulkTranslated. - A
MetricNamesdictionary 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.Abstractions10.0.5(direct, microsoft)Microsoft.Extensions.Logging.Abstractions10.0.5(direct, microsoft)Lyo.Common.Core(transitive, lyo)Microsoft.Bcl.AsyncInterfaces10.0.5(transitive, microsoft, netstandard2.0)System.Memory4.6.3(transitive, microsoft, netstandard2.0)System.Text.Json10.0.5(transitive, microsoft, netstandard2.0)
| Product | Versions 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. |
-
.NETStandard 2.0
- Lyo.Common.Metadata (>= 2.0.0)
- Lyo.Exceptions (>= 2.0.0)
- Lyo.Metrics (>= 2.0.0)
- Lyo.Result (>= 2.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
-
net10.0
- Lyo.Common.Metadata (>= 2.0.0)
- Lyo.Exceptions (>= 2.0.0)
- Lyo.Metrics (>= 2.0.0)
- Lyo.Result (>= 2.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
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.