Show translation diagnostics in admin
This commit is contained in:
@@ -753,6 +753,27 @@ label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
|
||||
}
|
||||
.message.admin { align-self: flex-end; background: #ecf8f3; border-color: #c7e8dc; }
|
||||
.message .by { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
|
||||
.translation-meta {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin-left: 4px;
|
||||
padding: 1px 6px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid #d8e5df;
|
||||
background: #f6faf8;
|
||||
color: #416256;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.translation-meta.translated { border-color: #b9dfca; background: #eef8f2; color: #1e7a47; }
|
||||
.translation-meta.failed { border-color: #f0b9b9; background: #fff1f1; color: #b42318; }
|
||||
.translation-meta.missing_key,
|
||||
.translation-meta.empty { border-color: #f1d29b; background: #fff7e8; color: #9a5b00; }
|
||||
.translation-meta.disabled,
|
||||
.translation-meta.skipped,
|
||||
.translation-meta.pending,
|
||||
.translation-meta.same_language { border-color: #d7dde2; background: #f5f7f8; color: #667085; }
|
||||
.message p { margin: 0; white-space: pre-wrap; }
|
||||
.message a { color: var(--brand); display: inline-block; margin-top: 6px; }
|
||||
.translation {
|
||||
|
||||
@@ -591,9 +591,47 @@ function renderActive() {
|
||||
${renderAttachments(message.attachments)}
|
||||
</article>
|
||||
`).join("") + adminReadReceipt(conversation, messages);
|
||||
decorateTranslationMeta(messages);
|
||||
$("#messages").scrollTop = $("#messages").scrollHeight;
|
||||
}
|
||||
|
||||
function decorateTranslationMeta(messages) {
|
||||
document.querySelectorAll("#messages .message .by").forEach((element, index) => {
|
||||
const meta = translationMeta(messages[index]);
|
||||
if (!meta) return;
|
||||
const badge = document.createElement("span");
|
||||
badge.className = `translation-meta ${meta.status}`;
|
||||
badge.textContent = meta.label;
|
||||
if (meta.error) badge.title = meta.error;
|
||||
element.append(" ");
|
||||
element.append(badge);
|
||||
});
|
||||
}
|
||||
|
||||
function translationMeta(message) {
|
||||
if (!message?.translationStatus) return null;
|
||||
const status = String(message.translationStatus || "");
|
||||
const source = String(message.originalLanguage || "?").toUpperCase();
|
||||
const target = String(message.translatedLanguage || "?").toUpperCase();
|
||||
return {
|
||||
status,
|
||||
error: message.translationError || "",
|
||||
label: translationStatusLabel(status, source, target)
|
||||
};
|
||||
}
|
||||
|
||||
function translationStatusLabel(status, source, target) {
|
||||
if (status === "translated") return `preklad: ${source} -> ${target}`;
|
||||
if (status === "same_language") return `preklad: ${source} = ${target}`;
|
||||
if (status === "failed") return `preklad: ${source} -> ${target} - chyba`;
|
||||
if (status === "missing_key") return "preklad: chybi klic";
|
||||
if (status === "disabled") return "preklad: vypnuto";
|
||||
if (status === "empty") return `preklad: ${source} -> ${target} - prazdny`;
|
||||
if (status === "skipped") return "preklad: preskoceno";
|
||||
if (status === "pending") return "preklad: ceka";
|
||||
return `preklad: ${status}`;
|
||||
}
|
||||
|
||||
function renderMessageBody(message) {
|
||||
const original = message.body ? `<p>${escapeHtml(message.body)}</p>` : "";
|
||||
if (!message.translatedBody) return original;
|
||||
|
||||
Reference in New Issue
Block a user