Bitzsoft.Integrations.Translation.DeepL
1.0.0
dotnet add package Bitzsoft.Integrations.Translation.DeepL --version 1.0.0
NuGet\Install-Package Bitzsoft.Integrations.Translation.DeepL -Version 1.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="Bitzsoft.Integrations.Translation.DeepL" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitzsoft.Integrations.Translation.DeepL" Version="1.0.0" />
<PackageReference Include="Bitzsoft.Integrations.Translation.DeepL" />
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 Bitzsoft.Integrations.Translation.DeepL --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Bitzsoft.Integrations.Translation.DeepL, 1.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 Bitzsoft.Integrations.Translation.DeepL@1.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=Bitzsoft.Integrations.Translation.DeepL&version=1.0.0
#tool nuget:?package=Bitzsoft.Integrations.Translation.DeepL&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Bitzsoft.Integrations.Translation.DeepL
DeepL API 实现包 -- v2/translate 原生批量与 detected_source_language 回显,context / glossary 术语约束,v2/usage 健康探测,实现 ITranslationProvider 统一契约。
功能特性
- 官方 API 直连:
Authorization: DeepL-Auth-Key鉴权,Pro / Free 端点一键切换 - 原生批量:
text数组单请求批量翻译,结果顺序一致并逐条回显检测语种 - 术语软约束:请求内
Terms拼接为context参数(不计费不翻译);配置GlossaryId走服务端术语表强约束 - 语言检测:截取前 100 字符微型翻译探测,回读
detected_source_language(产生最小计费字符) - 额度健康探测:
CheckHealthAsync走GET /v2/usage,附剩余字符额度;额度耗尽返回Degraded - 限流退避重试:net8+ 标准韧性 handler(429/529/503/504 指数退避),次数与基准延迟可配
- 请求审计:内置 RequestLogging 管道记录出站请求
安装
dotnet add package Bitzsoft.Integrations.Translation.DeepL
配置
appsettings.json
{
"Translation": {
"DeepL": {
"ApiKey": "your-deepl-auth-key",
"Plan": "Pro",
"GlossaryId": "",
"Formality": "default"
}
}
}
| 配置项 | 说明 | 必填 | 默认值 |
|---|---|---|---|
ApiKey |
DeepL-Auth-Key(继承统一 Options) | 是 | - |
Plan |
Pro(api.deepl.com)/ Free(api-free.deepl.com) |
否 | Pro |
BaseAddress |
端点覆盖(优先于 Plan) | 否 | - |
GlossaryId |
服务端术语表 ID(要求请求显式源语言) | 否 | 空 |
Formality |
译文正式度(more / less / prefer_more / prefer_less) | 否 | default |
Timeout |
HTTP 超时 | 否 | 30s |
MaxRetryAttempts / RetryBaseDelay |
限流退避重试次数 / 基准延迟 | 否 | 3 / 500ms |
HttpClientName |
命名 HttpClient 标识 | 否 | DeepLTranslationProvider |
注册服务
builder.Services.AddBitzsoftDeepLTranslation(builder.Configuration);
// 或 Free 计划
builder.Services.AddBitzsoftDeepLTranslation(options =>
{
options.ApiKey = "your-deepl-auth-key:fx";
options.Plan = "Free";
});
注册后 ITranslationProviderFactory 可按编码 deepl 解析。
使用示例
var provider = factory.GetProvider(TranslationProviderCode.DeepL);
var result = await provider.TranslateAsync(new TranslationTextRequest
{
Text = "Force majeure clause shall apply.",
SourceLanguage = "en",
TargetLanguage = "zh",
Terms = new[] { new TranslationTerm("force majeure", "不可抗力") }
});
能力矩阵
| 能力 | 支持 | 说明 |
|---|---|---|
| 单文本翻译 | ✅ | v2/translate(单请求上限 128 KiB) |
| 批量翻译 | ✅ | text 数组原生批量 |
| 语言检测 | ✅ | 微型翻译探测回读 detected_source_language |
| 领域词汇表(Terms) | ✅ 软约束 | 拼接 context;GlossaryId 提供服务端强约束 |
| HTML 格式 | ✅ | tag_handling 由调用方在 DeepL 控制台策略下按需启用(本包按纯文本 + preserve_formatting 传输) |
| 健康探测 | ✅ | GET /v2/usage 额度查询(不计费字符) |
已知限制:繁体中文目标统一映射 ZH(DeepL 以简体中文为主目标)。
错误码收敛
| DeepL 状态 / 信号 | 统一错误码 |
|---|---|
| 403(鉴权失败) | AuthenticationFailed |
| 400 + message 含 lang(语言不支持) | LanguageNotSupported |
| 400 / 413(参数 / 请求体过大) | InvalidArgument |
| 429 / 529(限流) | RateLimited |
| 456(配额耗尽,勿重试) | QuotaExceeded |
| 网络异常 / DNS 解析失败 | NetworkUnreachable |
| 超时 | Timeout |
相关包
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. 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 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. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.4)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.4)
- Bitzsoft.Integrations.Translation.Abstractions (>= 1.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Http (>= 10.0.10)
- Microsoft.Extensions.Http.Resilience (>= 10.7.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.10)
-
net5.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.4)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.4)
- Bitzsoft.Integrations.Translation.Abstractions (>= 1.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Http (>= 5.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 5.0.0)
-
net8.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.4)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.4)
- Bitzsoft.Integrations.Translation.Abstractions (>= 1.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Http (>= 10.0.10)
- Microsoft.Extensions.Http.Resilience (>= 10.7.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.10)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Bitzsoft.Integrations.Translation.DeepL:
| Package | Downloads |
|---|---|
|
Bitzsoft.Integrations.Translation.All
翻译服务聚合包 — 传统机翻(阿里云 / 百度 / 腾讯云 / 有道 / DeepL / Google 官方)+ AI 翻译(通义 Qwen-MT / 百度大模型 / 火山引擎大模型,OpenAI 兼容 / Anthropic net8+),配置存在性驱动注册 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 58 | 10/21/2026 |