feat(settings): mother-tongue language routing table
Replace the single reverse-direction pair with a general routing table. The saved target is the mother tongue and the default target for every source; languageRoutes is an empty-by-default, source-unique list of source-to-target rules (for example Chinese -> English, Traditional Chinese -> English, German -> English). Rules apply only when the source is confidently detected; otherwise the mother tongue is used. Same-language rules are dropped.\n\nThe panel shows the effective direction and a banner explaining a rule, with a one-capture override back to the mother tongue; the panel picker is now a session-only override. Persistent rules are edited in Settings. The old autoSwitchTarget/fallbackTargetLanguage keys are ignored, so the default after migration is everything -> mother tongue.\n\nAdd LanguageRoute, generalize the direction policy and tests, add the rules UI, and update ADR-022, architecture, translation output, user guide, README and progress. Verified: make verify green; empty rules translate French -> German, a Chinese -> English rule produces Chinese (Simplified) -> English with the banner, and the rules table renders in Settings.
This commit is contained in:
1 parent
41f1cea769
commit
940abcc996
24 files changed
+454
-336
No files matched your search
@@ -554,7 +554,7 @@ stateDiagram-v2
|
||||
| Onboarding | `NSWindow` (not a SwiftUI `Window` scene) | Ollama reachable + version, Hy-MT3 installed, target language, optional Accessibility for Replace; each with a fix button |
|
||||
| Diagnostics | Window from the menu | Server version, model digests, last 50 timings and error kinds; copy as text; no text or translations |
|
||||
|
||||
When the source is confidently detected as the saved target language, the panel can translate into the configured fallback target instead. The saved target and the effective target are separate: the header and language picker show the effective target, a banner explains the switch and offers a one-capture override, and the language picker still changes the saved target. Detection remains advisory and uses the same high-confidence rule as the same-language advisory.
|
||||
The saved target is the **mother tongue** and the default target for every source. Optional source-language to target-language rules override it when the source is confidently detected; otherwise the mother tongue is used. The mother tongue and the effective target are separate: the header and language picker show the effective target, a banner explains a rule-driven direction and offers a one-capture override back to the mother tongue, and the panel picker is a session-only override. Persistent rules live in Settings. Detection remains advisory and uses the same high-confidence rule as the same-language advisory.
|
||||
|
||||
Panel keyboard: **Esc** close, **⌘C** copy translation, **⌘↩** Replace, **⌘R** retry, **⌘,** Settings. The panel is made key when shown (unless the setting is off) so Esc and the shortcuts work without a click; the app is still not activated, the source app remains frontmost and owns the menu bar, and clicking the source app takes keyboard focus back. A click sent to another app dismisses the panel; while the panel is visible a transient mouse-down monitor observes only that the click went to another app, discards the event and is removed on close. While the panel is key it receives keystrokes, so a user who types immediately after triggering should disable the Esc-on-show setting. The whole header bar (full width, flush with the top edge) moves the panel; the drag view moves the window itself from the screen-space mouse delta because `performDrag` does nothing while the app is inactive; moving it keeps its position while it stays open, and a newly shown panel is placed near the cursor (DeepL-like transient position). The translation text size is a Settings value.
|
||||
|
||||
@@ -589,8 +589,7 @@ Accessibility: every control has an `accessibilityLabel`; the panel exposes sour
|
||||
| `autoCopy` | Bool | **false** (never copy automatically) |
|
||||
| `showSourcePreview` | Bool | true |
|
||||
| `translationFontSize` | Int | 17 pt (12–28) |
|
||||
| `autoSwitchTarget` | Bool | true (optional reverse direction when the source is already the target) |
|
||||
| `fallbackTargetLanguage` | String | `en` (or `de` when the target is English; always differs from the target) |
|
||||
| `languageRoutes` | [LanguageRoute] | `[]` (everything translates into the mother tongue unless a rule matches) |
|
||||
| `renderMarkdown` | Bool | true (presentation only; raw text is copied and replaced) |
|
||||
| `closeWithEscape` | Bool | true (make the panel key on show; no app activation) |
|
||||
| `launchAtLogin` | Bool | false |
|
||||
|
||||
Reference in new issue
Block a user