Show translation diagnostics in admin
This commit is contained in:
@@ -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