88555eb8a7
Add doc_picker_btn/audio_picker_btn to i18n.php (en/no/uk/pl), add docPickerBtn to REDACT_I18N + TIMELINE_I18N and audioPickerBtn to TRANSCRIBE_I18N in tools.js. PHP-render picker labels in legal-analysis, translate, summarize, tool_form, and layout_footer using dbnToolsT(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
147 lines
10 KiB
PHP
147 lines
10 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
$toolName = 'translate';
|
|
$toolTitle = 'Legal Translation';
|
|
$toolKind = 'Legal Translation';
|
|
$toolBadge = 'Azure · GPT-4o';
|
|
$extraScripts = ['assets/js/translate.js'];
|
|
require_once __DIR__ . '/includes/layout.php';
|
|
|
|
$ltLang = dbnToolsCurrentLanguage();
|
|
$ltT = static fn(string $k): string => dbnToolsT($k, $ltLang);
|
|
// Default source = Norwegian; target = UI language, but if UI=no, default to English
|
|
$ltDefaultTarget = ($ltLang === 'no') ? 'en' : $ltLang;
|
|
$ltI18n = [
|
|
'runButton' => $ltT('lt_run_button'),
|
|
'runButtonBusy' => $ltT('lt_run_button_busy'),
|
|
'extractingFiles' => $ltT('lt_extracting_files'),
|
|
'translatingStatus' => $ltT('lt_translating_status'),
|
|
'needInput' => $ltT('lt_need_input'),
|
|
'errorPrefix' => $ltT('lt_error_prefix'),
|
|
'serverReturned' => $ltT('lt_server_returned'),
|
|
'resultTitle' => $ltT('lt_result_title'),
|
|
'annotationsTitle' => $ltT('lt_annotations_title'),
|
|
'copyButton' => $ltT('lt_copy_button'),
|
|
'copyDone' => $ltT('lt_copy_done'),
|
|
'sameLangError' => $ltT('lt_same_lang_error'),
|
|
'disclaimer' => $ltT('lt_disclaimer'),
|
|
];
|
|
?>
|
|
<form id="ltForm" class="tool-form" novalidate>
|
|
|
|
<div class="lang-switcher" id="ltLangSwitcher" role="group" aria-label="UI language">
|
|
<button type="button" class="lang-btn lt-lang-btn <?= $ltLang === 'en' ? 'is-active' : '' ?>" data-lang="en">🇬🇧 EN</button>
|
|
<button type="button" class="lang-btn lt-lang-btn <?= $ltLang === 'no' ? 'is-active' : '' ?>" data-lang="no">🇳🇴 NO</button>
|
|
<button type="button" class="lang-btn lt-lang-btn <?= $ltLang === 'uk' ? 'is-active' : '' ?>" data-lang="uk">🇺🇦 UK</button>
|
|
<button type="button" class="lang-btn lt-lang-btn <?= $ltLang === 'pl' ? 'is-active' : '' ?>" data-lang="pl">🇵🇱 PL</button>
|
|
</div>
|
|
|
|
<div class="lt-source-target-row control-row">
|
|
<span class="control-label"><?= htmlspecialchars($ltT('lt_source_label')) ?></span>
|
|
<label><input type="radio" name="ltSourceLang" value="no" checked> 🇳🇴 NO</label>
|
|
<label><input type="radio" name="ltSourceLang" value="en"> 🇬🇧 EN</label>
|
|
<label><input type="radio" name="ltSourceLang" value="uk"> 🇺🇦 UK</label>
|
|
<label><input type="radio" name="ltSourceLang" value="pl"> 🇵🇱 PL</label>
|
|
</div>
|
|
|
|
<div class="lt-source-target-row control-row" id="ltTargetRow">
|
|
<span class="control-label"><?= htmlspecialchars($ltT('lt_target_label')) ?></span>
|
|
<label><input type="radio" name="ltTargetLang" value="en" <?= $ltDefaultTarget === 'en' ? 'checked' : '' ?>> 🇬🇧 EN</label>
|
|
<label><input type="radio" name="ltTargetLang" value="no" <?= $ltDefaultTarget === 'no' ? 'checked' : '' ?>> 🇳🇴 NO</label>
|
|
<label><input type="radio" name="ltTargetLang" value="uk" <?= $ltDefaultTarget === 'uk' ? 'checked' : '' ?>> 🇺🇦 UK</label>
|
|
<label><input type="radio" name="ltTargetLang" value="pl" <?= $ltDefaultTarget === 'pl' ? 'checked' : '' ?>> 🇵🇱 PL</label>
|
|
</div>
|
|
|
|
<div class="control-row" id="ltDocTypeControl">
|
|
<span class="control-label"><?= htmlspecialchars($ltT('lt_doc_type_label')) ?></span>
|
|
<label><input type="radio" name="ltDocType" value="auto" checked> <?= htmlspecialchars($ltT('la_doc_type_auto')) ?></label>
|
|
<label><input type="radio" name="ltDocType" value="barnevernet"> Barnevernet</label>
|
|
<label><input type="radio" name="ltDocType" value="adopsjon"> Adopsjon</label>
|
|
<label><input type="radio" name="ltDocType" value="emergency"> Akutt-plassering</label>
|
|
<label><input type="radio" name="ltDocType" value="samvær"> Samvær</label>
|
|
<label><input type="radio" name="ltDocType" value="fylkesnemnd"> Fylkesnemnd</label>
|
|
<label><input type="radio" name="ltDocType" value="other"> <?= htmlspecialchars($ltT('la_doc_type_other')) ?></label>
|
|
</div>
|
|
|
|
<p class="upload-hint"><?= htmlspecialchars($ltT('lt_engine_hint')) ?></p>
|
|
|
|
<div id="docPickerSection" class="doc-picker-section">
|
|
<button type="button" id="docPickerBtn" class="doc-picker-btn" aria-haspopup="dialog">
|
|
<svg class="doc-picker-btn__icon" width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><rect x="2" y="1" width="9" height="12" rx="1.5" stroke="currentColor" stroke-width="1.4"/><path d="M5 5h5M5 8h3" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/><rect x="7" y="9" width="6" height="5" rx="1" fill="white" stroke="currentColor" stroke-width="1.3"/><path d="M9 11h2M9 12.5h1" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>
|
|
<span><?= htmlspecialchars($ltT('doc_picker_btn')) ?></span>
|
|
</button>
|
|
<div id="docPickerChips" class="doc-picker-chips" aria-label="Selected documents"></div>
|
|
<input type="hidden" id="docPickerIds" name="doc_ids" value="">
|
|
</div>
|
|
|
|
<div class="upload-zone" id="ltUploadZone" role="region" aria-label="File upload">
|
|
<input type="file" id="ltUploadInput" multiple accept=".pdf,.docx,.txt" aria-label="Choose files to translate">
|
|
<div id="ltUploadPrompt" class="upload-prompt">
|
|
<span class="upload-icon" aria-hidden="true">⇧</span>
|
|
<p>Drop up to 5 files here, or <label for="ltUploadInput" class="upload-browse">browse</label></p>
|
|
<p class="upload-hint"><strong>PDF</strong>, <strong>DOCX</strong>, <strong>TXT</strong> — text extracted in memory, never stored</p>
|
|
</div>
|
|
<div id="ltUploadFileInfo" class="upload-file is-hidden">
|
|
<ul id="ltUploadFileList" class="upload-file-list"></ul>
|
|
<button type="button" id="ltUploadClear" class="upload-clear">× Clear files</button>
|
|
</div>
|
|
</div>
|
|
|
|
<label class="input-label" for="ltInput"><?= htmlspecialchars($ltT('lt_input_label')) ?> <small class="control-hint"><?= htmlspecialchars($ltT('lt_input_hint')) ?></small></label>
|
|
<textarea id="ltInput" name="text" rows="8" placeholder="<?= htmlspecialchars($ltT('lt_input_placeholder')) ?>"></textarea>
|
|
|
|
<div class="form-footer">
|
|
<p id="ltStatus" class="form-status" role="status" aria-live="polite"></p>
|
|
<button id="ltRunButton" type="submit"><?= htmlspecialchars($ltT('lt_run_button')) ?></button>
|
|
</div>
|
|
</form>
|
|
|
|
<section id="ltResults" class="results" aria-live="polite">
|
|
<div class="empty-state">
|
|
<h3><?= htmlspecialchars($ltT('lt_ready_title')) ?></h3>
|
|
<p><?= htmlspecialchars($ltT('lt_ready_intro')) ?></p>
|
|
</div>
|
|
</section>
|
|
|
|
<script>
|
|
window.DBN_LT_I18N = <?= json_encode($ltI18n, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>;
|
|
window.DBN_LT_LANG = <?= json_encode($ltLang) ?>;
|
|
</script>
|
|
|
|
<!-- Hidden stubs so tools.js element refs don't crash on this page -->
|
|
<div class="is-hidden" id="languageControl" aria-hidden="true">
|
|
<input type="radio" name="language" value="en" <?= $ltLang === 'en' ? 'checked' : '' ?>>
|
|
<input type="radio" name="language" value="no" <?= $ltLang === 'no' ? 'checked' : '' ?>>
|
|
<input type="radio" name="language" value="uk" <?= $ltLang === 'uk' ? 'checked' : '' ?>>
|
|
<input type="radio" name="language" value="pl" <?= $ltLang === 'pl' ? 'checked' : '' ?>>
|
|
</div>
|
|
<div class="is-hidden" id="redactionControl" aria-hidden="true"></div>
|
|
<div class="is-hidden" id="audioZone" aria-hidden="true">
|
|
<input type="file" id="audioInput" style="display:none">
|
|
<div id="audioPrompt"></div>
|
|
<div id="audioFileInfo"><ol id="audioQueueList"></ol><button type="button" id="audioClear"></button></div>
|
|
</div>
|
|
<div class="is-hidden" id="diarizeControl" aria-hidden="true">
|
|
<input type="checkbox" id="diarizeCheck">
|
|
<input type="number" id="numSpeakersInput">
|
|
</div>
|
|
<div class="is-hidden" id="transcribeLangControl" aria-hidden="true"><input type="radio" name="transcribeLang" value="no" checked></div>
|
|
<div class="is-hidden" id="vocabControl" aria-hidden="true">
|
|
<div id="vocabPresets"></div>
|
|
<textarea id="initPromptInput"></textarea>
|
|
</div>
|
|
<div class="is-hidden" id="aliasSection" aria-hidden="true">
|
|
<button type="button" id="addAliasRow"></button>
|
|
<div id="aliasRows"></div>
|
|
</div>
|
|
<div class="is-hidden" id="exemptSection" aria-hidden="true">
|
|
<button type="button" id="addExemptRow"></button>
|
|
<div id="exemptRows"></div>
|
|
</div>
|
|
<div class="is-hidden" id="uploadZone" aria-hidden="true">
|
|
<input type="file" id="uploadInput">
|
|
<div id="uploadPrompt"></div>
|
|
<div id="uploadFileInfo"><ul id="uploadFileList"></ul><button type="button" id="uploadClear"></button></div>
|
|
</div>
|
|
<?php require_once __DIR__ . '/includes/layout_footer.php'; ?>
|