Completa i18n IT/EN/FR/DE/ES su sito pubblico, area autenticata e admin.
Tutte le view marketing, legali, viewer, dashboard e admin usano t(); mailer utente-facing e flash localizzati; admin con LocaleResolver e selettore lingua. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,6 +3,63 @@
|
||||
var pendingScope = null;
|
||||
var dialog = null;
|
||||
|
||||
var DEFAULT_I18N = {
|
||||
eyebrow: "Conferma richiesta",
|
||||
title: "Sei sicuro?",
|
||||
deleteTitle: "Eliminare definitivamente?",
|
||||
confirmOk: "Conferma",
|
||||
deleteOk: "Elimina",
|
||||
cancel: "Annulla",
|
||||
multiDeleteTitle: "Cosa vuoi eliminare?",
|
||||
multiDeleteMessage: "Scegli dove rimuovere il replay. L'operazione è irreversibile.",
|
||||
deleteYoutubeTitle: "Eliminare da YouTube?",
|
||||
deleteYoutubeMessage: "Il video verrà rimosso da YouTube. Il replay resterà disponibile sul sito.",
|
||||
deleteYoutubeOk: "Elimina da YouTube",
|
||||
deleteSiteTitle: "Eliminare dal sito?",
|
||||
deleteSiteMessageWithYoutube: "Il replay verrà rimosso dal sito. Il video su YouTube resterà online.",
|
||||
deleteSiteMessageOnly: "Stai per eliminare definitivamente questo replay dal sito. L'operazione è irreversibile.",
|
||||
deleteSiteOk: "Elimina dal sito",
|
||||
choiceSiteLabel: "Solo dal sito",
|
||||
choiceSiteHintWithYoutube: "Il video resta su YouTube",
|
||||
choiceSiteHintOnly: "Rimuove i file dal sito",
|
||||
choiceYoutubeLabel: "Solo da YouTube",
|
||||
choiceYoutubeHintWithSite: "Resta disponibile sul sito",
|
||||
choiceYoutubeHintOnly: "Rimuove solo il video YouTube",
|
||||
choiceBothLabel: "Da sito e YouTube",
|
||||
choiceBothHint: "Eliminazione completa"
|
||||
};
|
||||
|
||||
function loadI18n() {
|
||||
var raw = document.body && document.body.getAttribute("data-confirm-i18n");
|
||||
if (!raw) return DEFAULT_I18N;
|
||||
try {
|
||||
var parsed = JSON.parse(raw);
|
||||
var merged = {};
|
||||
for (var key in DEFAULT_I18N) {
|
||||
merged[key] = parsed[key] || DEFAULT_I18N[key];
|
||||
}
|
||||
return merged;
|
||||
} catch (err) {
|
||||
return DEFAULT_I18N;
|
||||
}
|
||||
}
|
||||
|
||||
var I18N = loadI18n();
|
||||
|
||||
function escapeHtml(str) {
|
||||
return String(str == null ? "" : str).replace(/[&<>"']/g, function (ch) {
|
||||
return (
|
||||
{
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
'"': """,
|
||||
"'": "'"
|
||||
}[ch] || ch
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function ensureDialog() {
|
||||
if (dialog) return dialog;
|
||||
|
||||
@@ -15,26 +72,26 @@
|
||||
dialog.innerHTML =
|
||||
'<div class="site-confirm__backdrop" data-confirm-cancel></div>' +
|
||||
'<div class="site-confirm__panel site-confirm__panel--choices">' +
|
||||
' <p class="site-confirm__eyebrow">Conferma richiesta</p>' +
|
||||
' <h2 class="site-confirm__title" id="site-confirm-title">Sei sicuro?</h2>' +
|
||||
' <p class="site-confirm__eyebrow">' + escapeHtml(I18N.eyebrow) + '</p>' +
|
||||
' <h2 class="site-confirm__title" id="site-confirm-title">' + escapeHtml(I18N.title) + '</h2>' +
|
||||
' <p class="site-confirm__message" id="site-confirm-message"></p>' +
|
||||
' <div class="site-confirm__choices" id="site-confirm-choices" hidden>' +
|
||||
' <button type="button" class="site-confirm__choice" data-confirm-scope="site">' +
|
||||
" <span class=\"site-confirm__choice-label\">Solo dal sito</span>" +
|
||||
" <span class=\"site-confirm__choice-hint\" data-hint-site>Il video resta su YouTube</span>" +
|
||||
' <span class="site-confirm__choice-label">' + escapeHtml(I18N.choiceSiteLabel) + '</span>' +
|
||||
' <span class="site-confirm__choice-hint" data-hint-site>' + escapeHtml(I18N.choiceSiteHintWithYoutube) + '</span>' +
|
||||
" </button>" +
|
||||
' <button type="button" class="site-confirm__choice" data-confirm-scope="youtube">' +
|
||||
" <span class=\"site-confirm__choice-label\">Solo da YouTube</span>" +
|
||||
" <span class=\"site-confirm__choice-hint\" data-hint-youtube>Resta disponibile sul sito</span>" +
|
||||
' <span class="site-confirm__choice-label">' + escapeHtml(I18N.choiceYoutubeLabel) + '</span>' +
|
||||
' <span class="site-confirm__choice-hint" data-hint-youtube>' + escapeHtml(I18N.choiceYoutubeHintWithSite) + '</span>' +
|
||||
" </button>" +
|
||||
' <button type="button" class="site-confirm__choice site-confirm__choice--danger" data-confirm-scope="both">' +
|
||||
" <span class=\"site-confirm__choice-label\">Da sito e YouTube</span>" +
|
||||
" <span class=\"site-confirm__choice-hint\" data-hint-both>Eliminazione completa</span>" +
|
||||
' <span class="site-confirm__choice-label">' + escapeHtml(I18N.choiceBothLabel) + '</span>' +
|
||||
' <span class="site-confirm__choice-hint" data-hint-both>' + escapeHtml(I18N.choiceBothHint) + '</span>' +
|
||||
" </button>" +
|
||||
" </div>" +
|
||||
' <div class="site-confirm__actions">' +
|
||||
' <button type="button" class="btn btn-secondary site-confirm__btn" data-confirm-cancel>Annulla</button>' +
|
||||
' <button type="button" class="btn btn-primary site-confirm__btn site-confirm__btn--danger" data-confirm-ok>Elimina</button>' +
|
||||
' <button type="button" class="btn btn-secondary site-confirm__btn" data-confirm-cancel>' + escapeHtml(I18N.cancel) + '</button>' +
|
||||
' <button type="button" class="btn btn-primary site-confirm__btn site-confirm__btn--danger" data-confirm-ok>' + escapeHtml(I18N.deleteOk) + '</button>' +
|
||||
" </div>" +
|
||||
"</div>";
|
||||
|
||||
@@ -89,6 +146,7 @@
|
||||
options = options || {};
|
||||
var hasSite = options.hasSite !== false;
|
||||
var hasYoutube = !!options.hasYoutube;
|
||||
var isDelete = !!options.isDelete;
|
||||
var canSite = hasSite;
|
||||
var canYoutube = hasYoutube;
|
||||
var canBoth = hasSite && hasYoutube;
|
||||
@@ -116,29 +174,25 @@
|
||||
|
||||
if (titleEl) {
|
||||
if (multi) {
|
||||
titleEl.textContent = "Cosa vuoi eliminare?";
|
||||
titleEl.textContent = I18N.multiDeleteTitle;
|
||||
} else if (pendingScope === "youtube") {
|
||||
titleEl.textContent = "Eliminare da YouTube?";
|
||||
titleEl.textContent = I18N.deleteYoutubeTitle;
|
||||
} else if (pendingScope === "site") {
|
||||
titleEl.textContent = "Eliminare dal sito?";
|
||||
titleEl.textContent = I18N.deleteSiteTitle;
|
||||
} else {
|
||||
titleEl.textContent = /elimin/i.test(message)
|
||||
? "Eliminare definitivamente?"
|
||||
: "Confermi questa operazione?";
|
||||
titleEl.textContent = isDelete ? I18N.deleteTitle : I18N.title;
|
||||
}
|
||||
}
|
||||
|
||||
if (messageEl) {
|
||||
if (multi) {
|
||||
messageEl.textContent =
|
||||
"Scegli dove rimuovere il replay. L'operazione è irreversibile.";
|
||||
messageEl.textContent = I18N.multiDeleteMessage;
|
||||
} else if (pendingScope === "youtube") {
|
||||
messageEl.textContent =
|
||||
"Il video verrà rimosso da YouTube. Il replay resterà disponibile sul sito.";
|
||||
messageEl.textContent = I18N.deleteYoutubeMessage;
|
||||
} else if (pendingScope === "site") {
|
||||
messageEl.textContent = hasYoutube
|
||||
? "Il replay verrà rimosso dal sito. Il video su YouTube resterà online."
|
||||
: "Stai per eliminare definitivamente questo replay dal sito. L'operazione è irreversibile.";
|
||||
? I18N.deleteSiteMessageWithYoutube
|
||||
: I18N.deleteSiteMessageOnly;
|
||||
} else {
|
||||
messageEl.textContent = message;
|
||||
}
|
||||
@@ -149,9 +203,9 @@
|
||||
|
||||
if (okBtn instanceof HTMLElement) {
|
||||
okBtn.hidden = multi;
|
||||
if (pendingScope === "youtube") okBtn.textContent = "Elimina da YouTube";
|
||||
else if (pendingScope === "site") okBtn.textContent = "Elimina dal sito";
|
||||
else okBtn.textContent = /elimin/i.test(message) ? "Elimina" : "Conferma";
|
||||
if (pendingScope === "youtube") okBtn.textContent = I18N.deleteYoutubeOk;
|
||||
else if (pendingScope === "site") okBtn.textContent = I18N.deleteSiteOk;
|
||||
else okBtn.textContent = isDelete ? I18N.deleteOk : I18N.confirmOk;
|
||||
}
|
||||
|
||||
setChoiceVisible(siteBtn, canSite);
|
||||
@@ -163,15 +217,15 @@
|
||||
setChoiceEnabled(bothBtn, canBoth);
|
||||
if (hintSite) {
|
||||
hintSite.textContent = canYoutube
|
||||
? "Il video resta su YouTube"
|
||||
: "Rimuove i file dal sito";
|
||||
? I18N.choiceSiteHintWithYoutube
|
||||
: I18N.choiceSiteHintOnly;
|
||||
}
|
||||
if (hintYoutube) {
|
||||
hintYoutube.textContent = canSite
|
||||
? "Resta disponibile sul sito"
|
||||
: "Rimuove solo il video YouTube";
|
||||
? I18N.choiceYoutubeHintWithSite
|
||||
: I18N.choiceYoutubeHintOnly;
|
||||
}
|
||||
if (hintBoth) hintBoth.textContent = "Eliminazione completa";
|
||||
if (hintBoth) hintBoth.textContent = I18N.choiceBothHint;
|
||||
}
|
||||
|
||||
el.hidden = false;
|
||||
@@ -249,11 +303,14 @@
|
||||
mode === "delete-replay-youtube";
|
||||
var hasSiteAttr = form.getAttribute("data-has-site");
|
||||
var hasSite = hasSiteAttr == null ? true : hasSiteAttr === "1";
|
||||
var isDelete =
|
||||
form.getAttribute("data-confirm-kind") === "delete" || isReplayDelete;
|
||||
|
||||
openDialog(message, {
|
||||
multi: isReplayDelete,
|
||||
hasYoutube: hasYoutube,
|
||||
hasSite: hasSite
|
||||
hasSite: hasSite,
|
||||
isDelete: isDelete
|
||||
});
|
||||
},
|
||||
true
|
||||
|
||||
Reference in New Issue
Block a user