From a9ba22aafa325c4dfd98e67a1230422a0e809556 Mon Sep 17 00:00:00 2001 From: rajchales-monito Date: Thu, 30 Jul 2026 09:35:30 +0200 Subject: [PATCH] Clarify widget save translation action --- public/admin.html | 2 +- public/admin.js | 28 +++++++++++++++++++++++++++- server.js | 21 +++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/public/admin.html b/public/admin.html index 3244866..f6aa16b 100644 --- a/public/admin.html +++ b/public/admin.html @@ -165,7 +165,7 @@
- +
diff --git a/public/admin.js b/public/admin.js index 4eb848f..5fe9818 100644 --- a/public/admin.js +++ b/public/admin.js @@ -493,7 +493,18 @@ function widgetCopyForAdmin(settings, language) { placeholder: settings.placeholder?.[lang], sendLabel: settings.sendLabel?.[lang] }; - return { ...defaultWidgetCopy(lang), ...legacy, ...copy }; + return normalizeWidgetCopyForAdmin({ ...defaultWidgetCopy(lang), ...legacy, ...copy }, lang); +} + +function normalizeWidgetCopyForAdmin(copy, language) { + if (language !== "cs") return copy; + const defaults = defaultWidgetCopy("cs"); + const legacy = legacyCzechWidgetCopy(); + const normalized = { ...copy }; + for (const field of Object.keys(legacy)) { + if (normalized[field] === legacy[field]) normalized[field] = defaults[field]; + } + return normalized; } function defaultWidgetCopy(language) { @@ -525,6 +536,21 @@ function defaultWidgetCopy(language) { }; } +function legacyCzechWidgetCopy() { + return { + title: "Potrebujete poradit?", + intro: "Napiste nam. Odpovime co nejdrive.", + offlineIntro: "Ted nejsme online, ale zpravu nam muzete nechat.", + placeholder: "Napiste zpravu...", + sendLabel: "Odeslat", + dropzoneLabel: "Pridat fotku nebo pretahnout", + onlineLabel: "Jsme online", + newReplyLabel: "Nova odpoved", + infoText: "Zpravu a technicke udaje relace zpracujeme jen pro odpoved na vas dotaz.", + operatorReplyLabel: "odpovida" + }; +} + function syncLegacyWidgetCopy(settings) { settings.title = settings.title || {}; settings.intro = settings.intro || {}; diff --git a/server.js b/server.js index 3525046..025ba10 100644 --- a/server.js +++ b/server.js @@ -375,6 +375,25 @@ function defaultWidgetCopy(language) { }; } +function legacyCzechWidgetCopy() { + return { + title: "Potrebujete poradit?", + intro: "Napiste nam. Odpovime co nejdrive.", + offlineIntro: "Ted nejsme online, ale zpravu nam muzete nechat.", + placeholder: "Napiste zpravu...", + sendLabel: "Odeslat", + dropzoneLabel: "Pridat fotku nebo pretahnout", + onlineLabel: "Jsme online", + offlineLabel: "Offline", + newReplyLabel: "Nova odpoved", + typingLabel: "Operator pise...", + infoTitle: "GDPR informace", + infoText: "Zpravu a technicke udaje relace zpracujeme jen pro odpoved na vas dotaz.", + closeLabel: "Zmensit chat", + operatorReplyLabel: "odpovida" + }; +} + function configuredUsers() { const users = []; for (let i = 1; i < 50; i += 1) { @@ -1139,9 +1158,11 @@ function normalizeWidgetCopy(value, settings = {}) { function normalizeWidgetCopyEntry(value, language) { const defaults = defaultWidgetCopy(language === "en" ? "en" : "cs"); + const legacyCs = language === "cs" ? legacyCzechWidgetCopy() : null; const copy = {}; for (const field of WIDGET_COPY_FIELDS) { copy[field] = String(value?.[field] || defaults[field] || "").trim(); + if (legacyCs && copy[field] === legacyCs[field]) copy[field] = defaults[field]; } return copy; }