Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
db2a2ea
Avoid OLE clipboard materialization during selection capture
Stellar-He Oct 14, 2026
2ee5cb6
Center tray glyph and follow reading appearance settings
Stellar-He Oct 14, 2026
fc6e9e6
Expose existing translation providers with isolated caches
Stellar-He Oct 14, 2026
06212d1
Assert unsupported snapshots never request delayed data
Stellar-He Oct 14, 2026
9b6b49d
Verify saved tray appearance and canceled edits
Stellar-He Oct 14, 2026
61488ad
Expose focused tray checks and native test diagnostics
Stellar-He Oct 14, 2026
063d229
Run native clipboard fixtures on a fresh isolated thread
Stellar-He Oct 14, 2026
228c071
Add optional DeepL API with protected user credentials
Stellar-He Oct 14, 2026
3c6a862
Read protected-clipboard selections in an isolated helper
Stellar-He Oct 14, 2026
1bdf9d3
Follow the pointer target when web selection differs from keyboard focus
Stellar-He Oct 14, 2026
de5c179
Clarify pointer coordinates in selection helper documentation
Stellar-He Oct 14, 2026
92d79ab
Allow bounded time for cold UIA provider initialization
Stellar-He Oct 14, 2026
90d5dc2
Reject window manipulation before selection capture
Stellar-He Oct 14, 2026
ed5c63f
Treat successful empty selections as a quiet result
Stellar-He Oct 14, 2026
432552e
Classify selection context before clipboard access
Stellar-He Oct 14, 2026
71b8d60
Require text context before surfacing selection errors
Stellar-He Oct 14, 2026
e51b648
Distinguish Explorer item properties from text selections
Stellar-He Oct 14, 2026
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
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,37 @@ jobs:
- name: Build application
shell: pwsh
run: ./build.ps1
- name: Clipboard workflow regression
shell: pwsh
run: ./scripts/test-clipboard.ps1
- name: Native window gesture boundaries
shell: pwsh
run: ./scripts/test-gestures.ps1
- name: Non-text selection contexts
shell: pwsh
run: ./scripts/test-selection-context.ps1
- name: Translation providers and DeepL offline regression
shell: pwsh
run: ./scripts/test-providers.ps1
- name: Isolated native clipboard regression
shell: pwsh
run: ./scripts/test-clipboard.ps1 -Native
- name: Fetch and build pinned dictionary
shell: pwsh
run: ./scripts/download-dictionary.ps1
- name: Run offline self-test
shell: pwsh
run: ./scripts/test.ps1
- name: Real selection helper integration
shell: pwsh
run: ./scripts/test-selection.ps1
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: LightTranslate-windows-x64
path: |
dist/LightTranslate/LightTranslate.exe
dist/LightTranslate/LightTranslate.SelectionHost.exe
dist/LightTranslate/LightTranslate.exe.config
dist/LightTranslate/LightTranslate.ico
dist/LightTranslate/lexicon.dat
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ lexicon.idx
dictionary-build.txt
settings.json
status.log
deepl-key.bin
deepl-key.bin.*.tmp
self-test.json
.vs/
*.user
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- **选中即译**:拖选、双击选词或使用键盘选择文字,自动显示译文。
- **顺手收起**:点击、打字、滚动页面或切换应用时,浮层自动淡出。
- **单词本地快查**:约 76 万条 ECDICT 词库,支持离线查词,并补充常见编程术语。
- **句子在线翻译**:使用微软翻译接口,腾讯接口作为备用。
- **句子在线翻译**:默认使用微软翻译接口,腾讯接口作为备用;也可明确选择单一服务或自备密钥使用 DeepL 官方 API。
- **留足阅读时间**:鼠标悬停时保持显示,长译文可在浮层内滚动。
- **融入桌面**:圆角、淡入淡出、明暗主题和托盘开关。

Expand All @@ -32,9 +32,10 @@

## 按自己的习惯设置

在托盘“译”图标上右键,选择 **设置…**。面板分为“翻译、浮层、启动”三页,保存后生效:
在托盘“译”图标上右键,选择 **设置…**。面板分为“翻译、浮层、启动、DeepL”四页,保存后生效:

- **翻译**:自动划词开关、剪贴板取词开关、微软在线目标语言、单次选区长度上限、排除应用和最低英文占比。托盘开关会立即生效并同步到已打开的面板;面板中的改动在保存后应用。关闭剪贴板取词后不获取选区。目标语言只影响微软在线翻译,本地词库和腾讯备用仍输出中文。
- **翻译**:自动划词开关、选区取词开关、在线服务及目标语言、单次选区长度上限、排除应用和最低英文占比。托盘开关会立即生效并同步到已打开的面板;面板中的改动在保存后应用。关闭选区取词后不获取选区。目标语言影响微软和 DeepL;本地词库和腾讯仍输出中文。
- **DeepL**:手动输入 API 密钥,输入遮挡且不回填。留空保留现有密钥,清除需点击“保存”;取消不改变密钥。密钥用 Windows 当前用户 DPAPI 加密,单独存入应用目录的 `deepl-key.bin`,不写入 `settings.json`。换用户或电脑需重新输入。保存设置不联网验证。
- **启动**:读取实际的当前用户启动项,显示当前目录是否开机自启;只有改变选择并保存时才创建或移除启动快捷方式。不写入 `settings.json` 的自启标志,也不默认开启自启。保存失败会显示错误;配置保存失败时会尝试恢复启动项,恢复失败会显示实际状态供检查。

“浮层”页保留以下阅读设置;最低英文占比在“翻译”页:
Expand Down Expand Up @@ -80,9 +81,12 @@ pwsh -File .\startup.ps1 -Remove

## 文字如何处理

命中本地词库的文字在电脑上查询;其他文字发送给微软翻译,主服务失败时会尝试腾讯。
默认自动模式先查询本地词库,未命中时发送给微软翻译,失败后尝试腾讯;自动模式不会调用 DeepL。明确选择微软、腾讯或 DeepL 会跳过词库,只请求所选服务,失败不会自动切换。
选择 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) 为准;不内置任何每月免费额度承诺。认证、额度、限流和超时会显示各自提示,不自动重试计费请求。
译文缓存保存在当前进程内,退出后清空。程序默认不记录选区原文或用户译文。
取词通过临时复制选区完成,并尝试恢复原剪贴板;系统或剪贴板管理器可能保留复制记录。
先由独立的 `LightTranslate.SelectionHost.exe` 判断操作区域并读取 Windows UI Automation 文本选区。空选区、图标列表、树等非文本交互直接结束,不访问剪贴板;不会按应用名全局排除资源管理器,列表内重命名编辑框仍可取词。辅助进程限时退出,主程序不持有 UIA/COM 对象。分发或移动程序时请保留该辅助文件。
仅在确认是文本编辑框或文档、但不支持选区接口时,才尝试安全备份、临时复制和恢复剪贴板。图片或应用专用格式导致无法安全备份时不复制,并显示读取失败提示;不清空剪贴板,也不退回 OLE 快照。未知区域或尚未确认文本上下文的探测失败会安静结束并保留固定诊断码,不会发送复制命令;已确认文本区域的读取失败以及辅助程序缺失仍有明确提示。系统或剪贴板管理器仍可能保留实际执行过的临时复制记录。

## 从源码构建

Expand Down
6 changes: 5 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $compiler = Join-Path $framework 'csc.exe'
if (-not (Test-Path -LiteralPath $compiler)) { throw '.NET Framework 4.8 and its 64-bit compiler are required.' }
$outputPath = [System.IO.Path]::GetFullPath($OutputDirectory)
New-Item -ItemType Directory -Path $outputPath -Force | Out-Null
$references = @('System.dll','System.Core.dll','System.Net.Http.dll','System.Drawing.dll','System.Windows.Forms.dll','System.Web.Extensions.dll','System.Xaml.dll','Microsoft.VisualBasic.dll') |
$references = @('System.dll','System.Core.dll','System.Security.dll','System.Net.Http.dll','System.Drawing.dll','System.Windows.Forms.dll','System.Web.Extensions.dll','System.Xaml.dll','Microsoft.VisualBasic.dll') |
ForEach-Object { '/r:' + (Join-Path $framework $_) }
$references += @('WindowsBase.dll','PresentationCore.dll','PresentationFramework.dll') |
ForEach-Object { '/r:' + (Join-Path $framework ('WPF\' + $_)) }
Expand All @@ -21,6 +21,10 @@ $sourceFiles = @(Get-ChildItem -LiteralPath (Join-Path $PSScriptRoot 'src') -Fil
('/win32icon:' + (Join-Path $PSScriptRoot 'assets\LightTranslate.ico')) `
@references @sourceFiles
if ($LASTEXITCODE -ne 0) { throw 'Compilation failed.' }
$helperReferences = @('System.dll','System.Core.dll') | ForEach-Object { '/r:' + (Join-Path $framework $_) }
$helperReferences += @('WindowsBase.dll','UIAutomationClient.dll','UIAutomationTypes.dll') | ForEach-Object { '/r:' + (Join-Path $framework ('WPF\' + $_)) }
& $compiler /nologo /target:exe /platform:x64 /optimize+ ('/out:' + (Join-Path $outputPath 'LightTranslate.SelectionHost.exe')) ('/win32manifest:' + (Join-Path $PSScriptRoot 'src\LightTranslate.manifest')) @helperReferences (Join-Path $PSScriptRoot 'helpers\SelectionHost.cs')
if ($LASTEXITCODE -ne 0) { throw 'Selection helper compilation failed.' }
Copy-Item -LiteralPath (Join-Path $PSScriptRoot 'src\LightTranslate.exe.config'),
(Join-Path $PSScriptRoot 'LICENSE'), (Join-Path $PSScriptRoot 'README.md'),
(Join-Path $PSScriptRoot 'THIRD_PARTY_NOTICES.md') -Destination $outputPath
Expand Down
Loading
Loading