i18n all /dashboard/ corpus pages for en/no/uk/pl
- Add require_once bootstrap.php to all 6 dashboard page files so
dbnToolsT() is available before layout_dashboard.php is included
- Add dash_upload_category_lbl key to no/uk/pl sections of i18n.php
(was only in English); Kategori/Категорія/Kategoria
- Fix broken ternary on upload.php Category label — replace with
dbnToolsT('dash_upload_category_lbl', $uiLang)
- layout_dashboard.php outputs window.DBN_I18N with all js_* keys
so dashboard JS reads locale-aware strings from PHP translations
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+58
-32
@@ -1,76 +1,96 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
$dashboardPage = 'index';
|
||||
$dashboardTitle = 'Min korpus';
|
||||
$dashboardLead = 'Privat juridisk kunnskapsbase. Last opp, organiser, spør — alt holdes til din konto.';
|
||||
$dashboardTitle = dbnToolsT('dash_title_overview', dbnToolsCurrentLanguage());
|
||||
$dashboardLead = dbnToolsT('dash_lead_overview', dbnToolsCurrentLanguage());
|
||||
require_once __DIR__ . '/../includes/layout_dashboard.php';
|
||||
?>
|
||||
<section class="dash-kpis" id="dashKpis" aria-label="Corpus statistics">
|
||||
<div class="dash-kpi">
|
||||
<p class="dash-kpi__label">Dokumenter</p>
|
||||
<p class="dash-kpi__label" id="kpiLabelDocs"></p>
|
||||
<p class="dash-kpi__value" data-kpi="documents">—</p>
|
||||
<p class="dash-kpi__hint">av kvote</p>
|
||||
<p class="dash-kpi__hint" id="kpiHintQuota"></p>
|
||||
</div>
|
||||
<div class="dash-kpi">
|
||||
<p class="dash-kpi__label">Passasjer indeksert</p>
|
||||
<p class="dash-kpi__label" id="kpiLabelChunks"></p>
|
||||
<p class="dash-kpi__value" data-kpi="chunks">—</p>
|
||||
<p class="dash-kpi__hint">søkbare biter</p>
|
||||
<p class="dash-kpi__hint" id="kpiHintSearchable"></p>
|
||||
</div>
|
||||
<div class="dash-kpi">
|
||||
<p class="dash-kpi__label">Klare</p>
|
||||
<p class="dash-kpi__label" id="kpiLabelReady"></p>
|
||||
<p class="dash-kpi__value" data-kpi="ready">—</p>
|
||||
<p class="dash-kpi__hint">av totalt</p>
|
||||
<p class="dash-kpi__hint" id="kpiHintTotal"></p>
|
||||
</div>
|
||||
<div class="dash-kpi">
|
||||
<p class="dash-kpi__label">Siste opplasting</p>
|
||||
<p class="dash-kpi__label" id="kpiLabelLast"></p>
|
||||
<p class="dash-kpi__value" data-kpi="last_upload" style="font-size: 1.05rem;">—</p>
|
||||
<p class="dash-kpi__hint">dato</p>
|
||||
<p class="dash-kpi__hint" id="kpiHintDate"></p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="dash-card">
|
||||
<div class="dash-card__head">
|
||||
<h2>Kom i gang</h2>
|
||||
<h2 id="getStartedTitle"></h2>
|
||||
</div>
|
||||
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem;">
|
||||
<a class="dash-btn dash-btn--primary" href="/dashboard/upload.php">📥 Last opp dokumenter</a>
|
||||
<a class="dash-btn" href="/dashboard/chat.php">💬 Still et juridisk spørsmål</a>
|
||||
<a class="dash-btn" href="/dashboard/documents.php">📚 Bla gjennom korpus</a>
|
||||
<a class="dash-btn dash-btn--primary" href="/dashboard/upload.php" id="btnUpload"></a>
|
||||
<a class="dash-btn" href="/dashboard/chat.php" id="btnAsk"></a>
|
||||
<a class="dash-btn" href="/dashboard/documents.php" id="btnBrowse"></a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="dash-card">
|
||||
<div class="dash-card__head">
|
||||
<h2>Nylig aktivitet</h2>
|
||||
<h2 id="recentTitle"></h2>
|
||||
<div class="dash-card__actions">
|
||||
<a href="/dashboard/documents.php" class="dash-btn">Se alle →</a>
|
||||
<a href="/dashboard/documents.php" class="dash-btn" id="btnSeeAll"></a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="dashRecent" class="dash-loading">Laster…</div>
|
||||
<div id="dashRecent" class="dash-loading"></div>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
'use strict';
|
||||
const api = window.DBN_DASHBOARD.apiBase;
|
||||
const I18N = window.DBN_I18N || {};
|
||||
const api = window.DBN_DASHBOARD.apiBase;
|
||||
const loc = I18N.locale || 'en-GB';
|
||||
|
||||
document.getElementById('kpiLabelDocs').textContent = I18N.kpi_docs || 'Documents';
|
||||
document.getElementById('kpiHintQuota').textContent = I18N.kpi_of_quota || 'of quota';
|
||||
document.getElementById('kpiLabelChunks').textContent = I18N.kpi_chunks || 'Passages indexed';
|
||||
document.getElementById('kpiHintSearchable').textContent = I18N.kpi_searchable || 'searchable pieces';
|
||||
document.getElementById('kpiLabelReady').textContent = I18N.kpi_ready || 'Ready';
|
||||
document.getElementById('kpiHintTotal').textContent = I18N.kpi_of_total || 'of total';
|
||||
document.getElementById('kpiLabelLast').textContent = I18N.kpi_last || 'Last upload';
|
||||
document.getElementById('kpiHintDate').textContent = I18N.kpi_date_label || 'date';
|
||||
document.getElementById('getStartedTitle').textContent = I18N.get_started || 'Get started';
|
||||
document.getElementById('recentTitle').textContent = I18N.recent_activity || 'Recent activity';
|
||||
document.getElementById('btnUpload').textContent = I18N.upload_docs_btn || '📥 Upload documents';
|
||||
document.getElementById('btnAsk').textContent = I18N.ask_btn || '💬 Ask a legal question';
|
||||
document.getElementById('btnBrowse').textContent = I18N.browse_btn || '📚 Browse corpus';
|
||||
document.getElementById('btnSeeAll').textContent = I18N.see_all || 'See all →';
|
||||
document.getElementById('dashRecent').textContent = I18N.loading || 'Loading…';
|
||||
|
||||
function fmtDate(s) {
|
||||
if (!s) return '—';
|
||||
try {
|
||||
return new Date(s.replace(' ', 'T') + 'Z').toLocaleDateString('nb-NO',
|
||||
return new Date(s.replace(' ', 'T') + 'Z').toLocaleDateString(loc,
|
||||
{ day: 'numeric', month: 'short', year: 'numeric' });
|
||||
} catch (_) { return s; }
|
||||
}
|
||||
function fmtNum(n) { return n == null ? '—' : Number(n).toLocaleString('nb-NO'); }
|
||||
function fmtNum(n) { return n == null ? '—' : Number(n).toLocaleString(loc); }
|
||||
|
||||
function statusPill(status) {
|
||||
const cls = {
|
||||
ready: 'dash-status--ready',
|
||||
pending: 'dash-status--pending',
|
||||
processing: 'dash-status--processing',
|
||||
error: 'dash-status--error',
|
||||
ready: 'dash-status--ready', pending: 'dash-status--pending',
|
||||
processing: 'dash-status--processing', error: 'dash-status--error',
|
||||
}[status] || 'dash-status--pending';
|
||||
const label = { ready: 'Klar', pending: 'Venter', processing: 'Behandler', error: 'Feil' }[status] || status;
|
||||
const label = {
|
||||
ready: I18N.status_ready || 'Ready', pending: I18N.status_pending || 'Pending',
|
||||
processing: I18N.status_processing || 'Processing', error: I18N.status_error || 'Error',
|
||||
}[status] || status;
|
||||
return '<span class="dash-status ' + cls + '">' + label + '</span>';
|
||||
}
|
||||
|
||||
@@ -84,23 +104,29 @@ require_once __DIR__ . '/../includes/layout_dashboard.php';
|
||||
const ready = docs.filter(d => d.status === 'ready').length;
|
||||
const last = docs[0] ? docs[0].created_at : null;
|
||||
|
||||
document.querySelector('[data-kpi="documents"]').textContent = fmtNum(total);
|
||||
document.querySelector('[data-kpi="chunks"]').textContent = fmtNum(chunks);
|
||||
document.querySelector('[data-kpi="ready"]').textContent = ready + ' / ' + docs.length;
|
||||
document.querySelector('[data-kpi="documents"]').textContent = fmtNum(total);
|
||||
document.querySelector('[data-kpi="chunks"]').textContent = fmtNum(chunks);
|
||||
document.querySelector('[data-kpi="ready"]').textContent = ready + ' / ' + docs.length;
|
||||
document.querySelector('[data-kpi="last_upload"]').textContent = fmtDate(last);
|
||||
|
||||
const recent = document.getElementById('dashRecent');
|
||||
if (!docs.length) {
|
||||
recent.className = 'dash-empty';
|
||||
recent.innerHTML = '<span class="dash-empty__icon">📭</span>Ingen dokumenter ennå. '
|
||||
+ '<a href="/dashboard/upload.php">Last opp ditt første</a>.';
|
||||
recent.innerHTML = '<span class="dash-empty__icon">📭</span>'
|
||||
+ (I18N.empty_docs || 'No documents yet.') + ' '
|
||||
+ '<a href="/dashboard/upload.php">' + (I18N.empty_docs_link || 'Upload your first') + '</a>.';
|
||||
return;
|
||||
}
|
||||
recent.className = '';
|
||||
recent.innerHTML = '';
|
||||
const table = document.createElement('table');
|
||||
table.className = 'dash-doctable';
|
||||
table.innerHTML = '<thead><tr><th>Tittel</th><th>Status</th><th>Passasjer</th><th>Lagt til</th></tr></thead>';
|
||||
table.innerHTML = '<thead><tr>'
|
||||
+ '<th>' + (I18N.th_title || 'Title') + '</th>'
|
||||
+ '<th>' + (I18N.th_status || 'Status') + '</th>'
|
||||
+ '<th>' + (I18N.th_chunks || 'Passages') + '</th>'
|
||||
+ '<th>' + (I18N.th_added || 'Added') + '</th>'
|
||||
+ '</tr></thead>';
|
||||
const tbody = document.createElement('tbody');
|
||||
docs.slice(0, 8).forEach(doc => {
|
||||
const tr = document.createElement('tr');
|
||||
@@ -120,7 +146,7 @@ require_once __DIR__ . '/../includes/layout_dashboard.php';
|
||||
.catch(err => {
|
||||
const recent = document.getElementById('dashRecent');
|
||||
recent.className = 'dash-error';
|
||||
recent.textContent = 'Kunne ikke laste: ' + err.message;
|
||||
recent.textContent = (I18N.error_loading || 'Could not load: ') + err.message;
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user