Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Non-text selection contexts
shell: pwsh
run: ./scripts/test-selection-context.ps1
- name: Translation providers and DeepL offline regression
- name: Translation providers, DeepL and Index offline regression
shell: pwsh
run: ./scripts/test-providers.ps1
- name: Isolated native clipboard regression
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ pwsh -File .\startup.ps1 -Remove

## 文字如何处理

默认自动模式先查询本地词库,未命中时发送给微软翻译,失败后尝试腾讯;自动模式不会调用 DeepL。明确选择微软、腾讯或 DeepL 会跳过词库,只请求所选服务,失败不会自动切换。
默认自动模式先查询本地词库,未命中时发送给微软翻译,失败后尝试腾讯;自动模式不会调用 DeepL 或 Index。明确选择微软、腾讯、DeepL 或 Index 会跳过词库,只请求所选服务,失败不会自动切换。
选择“仅哔哩哔哩 Index”后,可在模型下拉中选择 `Index-Translate-2B`、`Index-Translate-9B` 或 `Index-Translate-35B-A3B`。模型选择随设置保存和回填;旧配置仍保留原服务,仅增加默认模型值 35B,不会自动启用 Index。三档来自[官方说明](https://github.com/bilibili/Index-Translate/blob/main/docs/image_translate_zh.md),在线服务可用性可能变化。
Index 直接以 C# HTTP 调用 `https://index-translate.bilibili.com/v1/chat/completions`,不需要密钥或本地代理。选中文字会发送给哔哩哔哩;程序不记录选区或响应正文。目标语言 `zh-Hans` / `zh-Hant` 分别指定简体 / 繁體中文。缓存按服务、模型、目标语言和原文隔离;切换设置会取消等待中的翻译。
Index 单次翻译总期限为 60 秒,429 最多尝试三次,按 Retry-After 或递增间隔等待;服务要求等待超过 10 秒时提示稍后重试并保留冷却期。取消与过期结果会丢弃,超时、限流、模型不可用和异常响应都有明确提示;不会静默更换模型。返回模型标识与选择不符时也会拒绝显示结果。
选择 DeepL 并保存密钥后,选中文字将发送给 DeepL,可能按账户套餐计费;未配置密钥时不请求 DeepL。只使用官方 `POST /v2/translate`,按密钥的 `:fx` 标记选择 `api-free.deepl.com`,其余使用 `api.deepl.com`,不接受自定义地址或 HTTP 重定向。简繁中文对应 `ZH-HANS`、`ZH-HANT`。
额度和费用以 [DeepL 当前 API 套餐](https://support.deepl.com/hc/en-us/articles/360021200939-DeepL-API-plans) 为准;不内置任何每月免费额度承诺。认证、额度、限流和超时会显示各自提示,不自动重试计费请求。
译文缓存保存在当前进程内,退出后清空。程序默认不记录选区原文或用户译文。
Expand Down
8 changes: 8 additions & 0 deletions docs/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,11 @@ text-unsupported,修复后均返回 non-text;比较不读取文件名、选
该分类比较不替代完整交互验收。人工测试只在专用目录的合成文件上进行,分别检查单选
及多选后横拖释放、框选、Esc 取消拖动、F2 后选取文件名文字并取消重命名;不拖动、
移动或覆盖用户真实文件。当前候选的最终鼠标交互结果需在部署后单独记录。

## Index 翻译专项验证

`scripts/test-index.ps1 -OutputDirectory <候选目录>` 只使用模拟 HTTP,覆盖三档模型参数、固定端点、无 Authorization、User-Agent、temperature=0、关闭思考、简繁中文提示词、响应解析、空结果、截断、模型不一致、HTTP 错误、60 秒总期限、取消、过期结果、限流退避和缓存隔离。配置测试覆盖旧字段迁移、原默认服务、三档保存及回填、取消、重置、失败回滚和无效配置。

仅在明确授权后使用 `-Online`:依次向三档发送同一固定公开短句 `The window closes automatically.`,将请求模型、返回模型、HTTP 状态、尝试次数、耗时、公开句译文和错误写入 `index-live-test.json`。它不读取用户选区、剪贴板或外部文档。文档列出的模型不等同于在线测试成功;以该文件中各档的实际结果为准。

原 `--self-test-offline` 也包含 Index 模拟测试;剪贴板、托盘、手势、外部选区辅助程序和已有翻译源测试继续保留。Index 的等待浮层最多等待至 60 秒请求期限;鼠标移开、切换窗口、开始新操作或保存设置仍会取消旧请求。
17 changes: 17 additions & 0 deletions scripts/test-index.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[CmdletBinding()]
param(
[string]$OutputDirectory = (Join-Path $PSScriptRoot '..\dist\LightTranslate'),
[switch]$Online
)
$ErrorActionPreference = 'Stop'
$outputPath = [System.IO.Path]::GetFullPath($OutputDirectory)
$exe = Join-Path $outputPath 'LightTranslate.exe'
if (-not (Test-Path -LiteralPath $exe)) { throw 'Build the candidate first.' }
$argument = if ($Online) { '--test-index-live' } else { '--self-test-index' }
$process = Start-Process -FilePath $exe -ArgumentList $argument -WindowStyle Hidden -PassThru
# Only waits for this test process; never starts or stops the normal application.
$limit = if ($Online) { 190000 } else { 30000 }
if (-not $process.WaitForExit($limit)) { throw ('Test still running; inspect PID ' + $process.Id) }
if ($process.ExitCode -ne 0) { throw ('Index test failed; see ' + (Join-Path $outputPath 'status.log')) }
$name = if ($Online) { 'index-live-test.json' } else { 'index-test.json' }
Get-Content -LiteralPath (Join-Path $outputPath $name) -Raw -Encoding UTF8
1 change: 1 addition & 0 deletions settings.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"ClipboardFallback": true,
"Target": "zh-Hans",
"TranslationProvider": "auto",
"IndexModel": "Index-Translate-35B-A3B",
"MaxSelectionLength": 2000,
"ExcludedApps": [],
"Diagnostics": false,
Expand Down
Loading
Loading