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

+19 -11
View File
@@ -43,20 +43,28 @@ 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
### Mother tongue and language rules
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**:
The **mother tongue** is the default target for every source language. In
**Settings ▸ General ▸ Translation**, you can add **language rules** that override the default for
specific source languages:
- **Translate the other direction when the text is already in the target language** (on by default).
- **Fallback target language** (English by default).
```text
Mother tongue: German
Language rules:
Chinese (Simplified) → English
Traditional Chinese → English
German → English
```
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.
With the table above, Chinese and German text go to English, and every other language goes to
German. An empty table means everything goes to the mother tongue.
Rules run in the order shown; a source language appears at most once. Rules apply only when the
source is confidently detected; short or mixed text keeps the mother tongue. When a rule applies,
the panel header shows the effective direction and a banner offers a one-capture override back to
the mother tongue. Choosing a language from the panel picker also overrides the current result only;
manage persistent rules in Settings.
## 4. Services and the menu bar