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

+15
View File
@@ -43,6 +43,21 @@ the Hy-MT3 model and the target language. You can reopen setup from the menu bar
Replace is explicit; nothing is inserted automatically. Replace needs the macOS Accessibility
permission. Double copy, translation, Copy and the Services menu work without it.
### Translating the other direction
By default the panel also handles the opposite direction. With target **German** and fallback
**English**, English text becomes German and German text becomes English. This is controlled in
**Settings ▸ General ▸ Translation**:
- **Translate the other direction when the text is already in the target language** (on by default).
- **Fallback target language** (English by default).
The header shows the actual direction, and a banner explains an automatic switch. **Translate to
German** (or the original target) overrides the direction for that result only; the saved target
does not change. Choosing a language from the panel's picker does change the saved target. The
switch happens only when the text is confidently detected as the target language; short or mixed
text keeps the normal direction.
## 4. Services and the menu bar
- **Services ▸ Translate with Sprachmittler** translates the current selection without polling