feat(panel): optional reverse direction for target-language text

Add opt-in automatic reverse translation for a two-language pair. autoSwitchTarget defaults on with fallbackTargetLanguage English (or German when the target is English); the saved target and the effective request target are separate. Confident source-equals-target text uses the fallback, the header and a panel banner show the effective direction, and the banner can override the direction for one capture without changing the saved target. The language picker still changes the saved target, and changing the target to the fallback swaps the pair. JSON/HTML/code handling is unchanged.\n\nFilter near-zero NLLanguageRecognizer hypotheses so the existing high-confidence same-language rule works for real text. Add resolver, settings, view-model, detector and persistence tests; document ADR-022, the panel, settings and user guide. Verified: make verify green; German text with target German/fallback English renders German → English with the banner, English text stays English → German, a real click on the override shows German → German, and a new German capture switches back to English.
This commit is contained in:
schihei committed 2026-11-26 17:34:11 +01:00
1 parent 7c9cece201
commit 41f1cea769
24 files changed
+723 -148

No files matched your search

+6 -1
View File
@@ -13,6 +13,7 @@ A user-facing installation, permission and troubleshooting guide is in [docs/USE
- Double-copy trigger in any app: select, **⌘C**, **⌘C**.
- Streaming translations from a local Hy-MT3 model; no cloud API.
- 102 supported languages with a language picker and recent targets.
- Automatic reverse direction: with target German and fallback English, German text is translated to English and English text to German.
- Markdown rendering for headings, bold, italic, lists, quotes, code and links.
- Configurable translation text size, source-preview toggle and an optional Fast model preset.
@@ -102,6 +103,10 @@ The panel takes keyboard focus while it is visible by default, so Esc and the sh
| Replace the selection | **⌘↩** |
| Settings | **⌘,** |
### Translating the other direction
When the source is confidently detected as the saved target language, the panel translates into the configured fallback language instead. The header and banner show the effective direction, and the banner offers a one-capture override. **Settings ▸ General ▸ Translation** controls this; it is on by default with English as the fallback (German when the target is English).
### Markdown
When the source looks like Markdown and **Settings ▸ General ▸ Translation ▸ Render Markdown formatting** is on (the default), the translation is rendered with headings, bold, italic, lists, quotes, fenced code and links. JSON, HTML and code sources are never Markdown-rendered. **Copy** and **Replace** always use the raw Markdown translation, not the rendered text. Only `http` and `https` links open, and only on an explicit click.
@@ -112,7 +117,7 @@ Replace verifies the source app and, when available, the selected text before to
### Settings
- **General** — target language, source preview, Markdown rendering, translation text size, Esc behaviour, double-copy window and startup.
- **General** — target language, fallback target language, source preview, Markdown rendering, translation text size, Esc behaviour, double-copy window and startup.
- **Model** — model and Fast preset, Ollama endpoint, sampling and context settings.
- **Translation** — chunking and prompt policy.
- **Privacy** — local/remote endpoint policy and permissions.