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:
schihei committed 2026-11-26 18:31:45 +01:00
1 parent 41f1cea769
commit 940abcc996
24 files changed
+454 -336

No files matched your search

+13 -4
View File
@@ -13,7 +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.
- Language routing: a mother tongue default (e.g. everything to German) plus optional source-to-target rules (e.g. Chinese → English).
- Markdown rendering for headings, bold, italic, lists, quotes, code and links.
- Configurable translation text size, source-preview toggle and an optional Fast model preset.
@@ -103,9 +103,18 @@ The panel takes keyboard focus while it is visible by default, so Esc and the sh
| Replace the selection | **⌘↩** |
| Settings | **⌘,** |
### Translating the other direction
### Mother tongue and language rules
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).
The **mother tongue** is the default target for every source. In **Settings ▸ General ▸ Translation** you can add **language rules** that override it for a specific source language, for example:
```text
Mother tongue: German
Chinese (Simplified) → English
Traditional Chinese → English
German → English
```
With no rules, every language goes to the mother tongue. Rules apply only when the source is confidently detected; otherwise the mother tongue is used. The panel header shows the effective direction, a banner explains a rule and offers a one-capture override, and the panel language picker is a session-only override. Persistent rules live in Settings.
### Markdown
@@ -117,7 +126,7 @@ Replace verifies the source app and, when available, the selected text before to
### Settings
- **General** — target language, fallback target language, source preview, Markdown rendering, translation text size, Esc behaviour, double-copy window and startup.
- **General** — mother tongue, language rules, 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.