feat: add Legal Translation tool (translate.php)

New dedicated tool for translating Norwegian legal documents (Barnevernet
letters, court decisions, correspondence) into the user's chosen language
with legal-terminology annotations.

- translate.php: new tool page with source/target language selectors,
  4-way UI lang switcher, file upload, doc picker, streaming results
- api/translate.php: NDJSON streaming endpoint; Azure GPT-4o-mini with
  legal-aware prompt that preserves Norwegian statute refs verbatim and
  annotates terms with no target-language equivalent; 2-credit cost
- assets/js/translate.js: form handler, NDJSON stream reader, copy button
- assets/css/tools.css: .lt-* styles for translation result + annotations
- includes/i18n.php: 22 lt_* keys × 4 languages; translate entry in nav
- includes/FreeTier.php: translate → 2 credits
- includes/CaseResults.php + case-result.php: translate in eligible tools,
  toolLabel, toolIcon, deriveTitle, rendering block, rerun map

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-24 09:59:06 +02:00
parent 21c092e0d0
commit effd3289b4
8 changed files with 842 additions and 1 deletions
+54
View File
@@ -9397,3 +9397,57 @@ body.lt-landing {
}
.la-synthesis h3 { margin-top: 0; color: #0e7490; }
.la-synthesis h4 { margin: 0.9rem 0 0.4rem; font-size: 0.95rem; color: #155e75; }
/* ── Legal Translation ─────────────────────────────────────────────────── */
.lt-source-target-row { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.75rem; }
.lt-source-target-row .control-label { min-width: 8rem; font-weight: 600; }
.lt-result { margin-bottom: 1.4rem; }
.lt-result__head {
display: flex;
align-items: center;
gap: 0.75rem;
flex-wrap: wrap;
margin-bottom: 0.75rem;
}
.lt-result__head h3 { margin: 0; }
.lt-lang-pair {
font-size: 0.8rem;
font-family: monospace;
background: var(--surface-2, #f1f5f9);
border: 1px solid var(--border, #cbd5e1);
border-radius: 4px;
padding: 0.2rem 0.5rem;
color: #475569;
}
.lt-translated-text {
white-space: pre-wrap;
font-size: 0.95rem;
line-height: 1.75;
border: 1px solid var(--border, #cbd5e1);
border-radius: 8px;
padding: 1.25rem 1.5rem;
background: var(--surface-2, #f8fafc);
color: #1e293b;
max-height: 60vh;
overflow-y: auto;
}
.lt-copy-btn {
margin-left: auto;
font-size: 0.83rem;
padding: 0.3rem 0.75rem;
}
.lt-annotations { margin-top: 1.5rem; }
.lt-annotations h4 { margin: 0 0 0.6rem; font-size: 0.9rem; color: #475569; }
.lt-annotation {
background: var(--surface-2, #f8fafc);
border-left: 3px solid var(--accent, #0f766e);
padding: 0.45rem 0.75rem;
margin-bottom: 0.45rem;
border-radius: 0 6px 6px 0;
font-size: 0.87rem;
line-height: 1.5;
color: #334155;
}
.lt-annotation strong { font-family: monospace; color: #0e7490; }
.lt-busy { padding: 2rem; text-align: center; color: #64748b; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }