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:
1 parent
7c9cece201
commit
41f1cea769
24 files changed
+723
-148
No files matched your search
+8
-1
@@ -149,4 +149,11 @@ Status: Accepted
|
||||
|
||||
Context: Hy-MT3 preserves Markdown structure, but a plain `Text` showed `**bold**`, headings and lists literally. Users translating Markdown want the formatting rendered, while Copy and Replace must keep the Markdown that the model produced and the validator checked.
|
||||
Decision: Parse presentation Markdown in `SprachmittlerText` with Foundation's inline Markdown parser plus a small, conservative block parser (headings, lists, quotes, fenced code, rules, paragraphs). `MarkdownPresentation.shouldRender` rejects JSON, HTML and code sources and otherwise requires block or inline Markdown markers. The panel renders only when the setting `renderMarkdown` is on (default). Copy and Replace use the raw translation unchanged. Only `http` and `https` links open, on an explicit click; image syntax is reduced to alt text and no remote resource is fetched. Tables, raw HTML and nested lists/quotes remain plain text in this pass.
|
||||
Consequences: Rendering never rewrites the translation or weakens validation. Literal markers can be interpreted as formatting, so the setting is the escape hatch; Copy always returns the raw Markdown. The block layout makes text selection per block, while Copy remains the whole-translation path. No new dependency is added.
|
||||
Consequences: Rendering never rewrites the translation or weakens validation. Literal markers can be interpreted as formatting, so the setting is the escape hatch; Copy always returns the raw Markdown. The block layout makes text selection per block, while Copy remains the whole-translation path. No new dependency is added.
|
||||
|
||||
## ADR-022 — Optional reverse direction for source-equals-target text
|
||||
Status: Accepted
|
||||
|
||||
Context: A single saved target language is simple, but selecting text that is already in that language produced a same-language translation and an advisory. Users working in a two-language pair want the opposite direction automatically: with target German and fallback English, German text should become English and English text should become German.
|
||||
Decision: Add `autoSwitchTarget` (default true) and `fallbackTargetLanguage` (default English, or the other language when the target is English). Detect the source before the request and, only when the existing high-confidence same-language rule holds, use the fallback as the effective target. Keep the saved target separate from the effective target; the header and language picker show the effective one, and a panel banner offers a one-capture override that does not persist. A language-picker change persists the saved target. The fallback is kept different from the target; changing the target to the fallback swaps the pair to the previous target.
|
||||
Consequences: Confident two-language text translates in the useful direction without extra clicks. Uncertain, short or mixed text keeps the saved target, and the same-language advisory still appears when no switch occurs. Detection is advisory, so a wrong dominant language can choose the wrong direction; the banner and the language picker make it visible and recoverable. The effective target is what the prompt, chunking and validation use; Copy and Replace are unaffected. No key tap, permission or new dependency is added.
|
||||
Reference in new issue
Block a user