Bitzsoft.Integrations.Translation.Tencent
1.0.0
dotnet add package Bitzsoft.Integrations.Translation.Tencent --version 1.0.0
NuGet\Install-Package Bitzsoft.Integrations.Translation.Tencent -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.Tencent" 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.Tencent" Version="1.0.0" />
<PackageReference Include="Bitzsoft.Integrations.Translation.Tencent" />
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.Tencent --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.Tencent, 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.Tencent@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.Tencent&version=1.0.0
#tool nuget:?package=Bitzsoft.Integrations.Translation.Tencent&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Bitzsoft.Integrations.Translation.Tencent
腾讯云机器翻译(TMT)实现包 -- TextTranslate / TextTranslateBatch / TextDetect,TC3-HMAC-SHA256 签名,实现 ITranslationProvider 统一契约。
功能特性
- 官方 API 直连:裸 HttpClient 直调 TMT API 3.0,零厂商 SDK 依赖
- 原生批量:批量翻译走
TextTranslateBatch单请求多文本,结果顺序一致 - 独立语言检测:
TextDetect接口,检测结果无需翻译即可获得 - auto 源语言:
Source=auto时响应Source回显检测语种 - TC3-HMAC-SHA256 签名:内置腾讯云 API 3.0 签名
- 限流退避重试:net8+ 标准韧性 handler(429/503/504 指数退避),次数与基准延迟可配
- 请求审计:内置 RequestLogging 管道记录出站请求
- 健康探测:
CheckHealthAsync以最小代价(TextDetect 单字符)探测可用性
安装
dotnet add package Bitzsoft.Integrations.Translation.Tencent
配置
appsettings.json
{
"Translation": {
"Tencent": {
"AppId": "your-secret-id",
"AppSecret": "your-secret-key",
"Region": "ap-guangzhou",
"ProjectId": 0
}
}
}
| 配置项 | 说明 | 必填 | 默认值 |
|---|---|---|---|
AppId |
腾讯云 SecretId(继承统一 Options) | 是 | - |
AppSecret |
腾讯云 SecretKey(TC3 签名用,脱敏落日志) | 是 | - |
Endpoint |
TMT 服务端点 | 否 | tmt.tencentcloudapi.com |
BaseAddress |
端点覆盖(优先于 Endpoint,含协议) | 否 | - |
Region |
地域 | 否 | ap-guangzhou |
ProjectId |
腾讯云项目 ID(默认项目填 0) | 否 | 0 |
Timeout |
HTTP 超时 | 否 | 30s |
MaxRetryAttempts / RetryBaseDelay |
限流退避重试次数 / 基准延迟 | 否 | 3 / 500ms |
HttpClientName |
命名 HttpClient 标识 | 否 | TencentTranslationProvider |
注册服务
builder.Services.AddBitzsoftTencentTranslation(builder.Configuration);
// 或委托配置
builder.Services.AddBitzsoftTencentTranslation(options =>
{
options.AppId = "your-secret-id";
options.AppSecret = "your-secret-key";
});
注册后 ITranslationProviderFactory 可按编码 tencent 解析。
使用示例
var provider = factory.GetProvider(TranslationProviderCode.Tencent);
// 批量(原生单请求)
var batch = await provider.TranslateBatchAsync(new TranslationBatchRequest
{
Texts = new[] { "第一条", "第二条" },
SourceLanguage = "auto",
TargetLanguage = "en"
});
// 独立语言检测
var detected = await provider.DetectLanguageAsync(new TranslationDetectRequest { Text = "Hello" });
能力矩阵
| 能力 | 支持 | 说明 |
|---|---|---|
| 单文本翻译 | ✅ | TextTranslate(单条上限 2000 字符) |
| 批量翻译 | ✅ | TextTranslateBatch 原生批量(单请求总量上限 2000 字符) |
| 语言检测 | ✅ | TextDetect 独立接口 |
| 领域词汇表(Terms) | ❌ | 腾讯术语库在控制台维护;请求内 Terms 被忽略 |
| HTML 格式 | ❌ | 文本翻译不保留标签结构 |
| 健康探测 | ✅ | TextDetect 单字符探测 |
错误码收敛
| 腾讯云原始错误码 | 统一错误码 |
|---|---|
AuthFailure.* |
AuthenticationFailed |
InvalidParameterValue.UnsupportedLanguage 等 |
LanguageNotSupported |
InvalidParameter* |
InvalidArgument |
LimitExceeded.* |
RateLimited |
FailedOperation.NoFreeAmount / ResourceInsufficient |
QuotaExceeded |
UnsupportedRegion |
AccessDenied |
| 网络异常 / 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.Tencent:
| 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 | 63 | 10/21/2026 |