diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index c748bb1b..4e05633e 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -41,6 +41,8 @@ jobs: run: node build.mjs --check - name: Test motori frontend run: node --test test/engines.test.mjs + - name: Test dei testi dell'interfaccia in più lingue + run: node --test test/i18n.test.mjs - name: Test pagine della biglietteria run: node --test test/biglietteria.test.mjs test/bgl-*.test.mjs - name: Test del programma di sala @@ -84,12 +86,13 @@ jobs: run: | mkdir -p _site rsync -a --exclude='.DS_Store' --exclude='README.md' --exclude='orchestre/test/' --exclude='orchestre/demo/' \ + --exclude='i18n/it.json' --exclude='i18n/lingue.json' --exclude='i18n/cricchetto.json' \ .nojekyll 404.html CNAME LICENSE \ index.html app app.js icons.js icons-piedi.js icons-pro.js sw.js manifest.webmanifest \ robots.txt sitemap.xml llms.txt 4d1fdc8b5b357ff5353a9e928c187bff.txt \ favicon.ico favicon.svg favicon-48.png favicon-96.png \ apple-touch-icon.png icon-192.png icon-512.png logo-512.png preview.png \ - accedi alternative biglietteria consulenza guida i img inventario orchestre privacy produzione programma richiesta rider-tecnico-completo stage-plot termini vendor voce workshop \ + accedi alternative biglietteria consulenza guida i i18n img inventario orchestre privacy produzione programma richiesta rider-tecnico-completo stage-plot termini vendor voce workshop \ ./_site/ - name: Timbra il build ID (SHA del commit) negli asset pubblicati (audit L-03) # il placeholder sta nella shell dell'editor (app/index.html), non nella landing diff --git a/.github/workflows/pr-controlli.yml b/.github/workflows/pr-controlli.yml index b6ae5e95..b735a5f2 100644 --- a/.github/workflows/pr-controlli.yml +++ b/.github/workflows/pr-controlli.yml @@ -33,6 +33,8 @@ jobs: run: node build.mjs --check - name: Test motori frontend run: node --test test/engines.test.mjs + - name: Test dei testi dell'interfaccia in più lingue + run: node --test test/i18n.test.mjs - name: Test pagine della biglietteria run: node --test test/biglietteria.test.mjs test/bgl-*.test.mjs - name: Test del programma di sala diff --git a/app.js b/app.js index 11f7d9cd..0d34ec87 100644 --- a/app.js +++ b/app.js @@ -1,5 +1,136 @@ "use strict"; +/* ============ I18N (lotto L2, 30/11/2026): i testi dell'interfaccia in più lingue, UNA modifica sola ============ + Fonte unica: i18n/it.json (l'italiano). Le altre lingue sono file con le STESSE chiavi: i18n/en.json, … + Una chiave che manca in una lingua mostra l'italiano (mai un campo vuoto) e il test i18n la segnala. + + Tre strade, un solo catalogo: + 1. HTML: nel template si scrive ⟦chiave⟧ al posto del testo (anche dentro title, aria-label, placeholder, alt). + Il build mette l'italiano preso da it.json e segna l'elemento (data-t, data-t-title…). Qui sotto, in italiano + NON si tocca niente (zero lavoro per chi usa l'app oggi); in un'altra lingua i testi si sostituiscono, e + l'italiano originale resta memorizzato per tornare indietro. + 2. JS, interfaccia: t(«chiave», {n: 3}) → testo nella lingua dell'app. + 3. JS, documento (PDF, liste): td(«chiave», …) → stessa cosa nella lingua del DOCUMENTO (docLingua()). + Plurali: chiave_one / chiave_other (altre categorie secondo Intl.PluralRules) con segnaposto {n}; segnaposto {nome}. + Mai chiavi costruite a pezzi (t(«a.»+x)): il test cerca ogni chiave scritta per intero, tra virgolette. + + Lingua dell'app (L2): solo con ?lang=en (inglese) o ?lang=xx (pseudo-lingua: ogni testo diventa «[Ŝàlvà~~~]», più + lungo del 35 %, per vedere subito cosa non è estratto e cosa trabocca). Nessun selettore, nessun rilevamento dal + browser: sono L4. La lingua dell'app è una preferenza della persona, MAI nel progetto (docLang resta quella del documento). */ +var I18N_BUILD={"it":{"barra.libero":"Libero","barra.soloOggetti":"Solo oggetti","esporta.annulla":"Annulla","esporta.chiudi":"Chiudi","esporta.errore":"Errore: {msg}","esporta.foglioCambiScaricato_one":"✓ Foglio dei cambi scaricato ({n} pagina).","esporta.foglioCambiScaricato_other":"✓ Foglio dei cambi scaricato ({n} pagine).","esporta.foglioTeatroScaricato_one":"✓ Foglio per il teatro scaricato ({n} pagina, A4).","esporta.foglioTeatroScaricato_other":"✓ Foglio per il teatro scaricato ({n} pagine, A4).","esporta.generoBreve":"Genero…","esporta.generoFoglioCambi":"Genero il foglio dei cambi…","esporta.generoFoglioTeatro":"Genero il foglio per il teatro…","esporta.generoPalcoEsterni":"Genero il palco per esterni…","esporta.generoPdf":"Genero il PDF…","esporta.orientOrizzontale":"orizzontale","esporta.orientVerticale":"verticale","esporta.pacchettoProgresso":"Genero {i} di {n}: {nome}…","esporta.palcoEsterniScaricato":"Palco per esterni scaricato ({foglio} {orient}, scala 1:{scala}).","esporta.palcoEsterniScaricatoParziale":"Palco per esterni scaricato ({foglio} {orient}, scala 1:{scala}) — stampata solo la parte centrale che ci sta nel foglio."},"lingue":["en"]}; +var I18N={lang:"it", dict:{it:(I18N_BUILD.it||{})}, caricando:{}, orig:(typeof WeakMap==="function"?new WeakMap():null)}; + +/* Pseudo-lingua: lettere accentate, testo più lungo del 35 %, segnaposto {x}, tag e &entità intatti */ +function i18nPseudo(s){ + var m={a:"à",b:"ƀ",c:"ç",d:"ď",e:"é",f:"ƒ",g:"ĝ",h:"ĥ",i:"î",j:"ĵ",k:"ķ",l:"ļ",n:"ñ",o:"ö",p:"ƥ",q:"ǫ",r:"ŕ",s:"š",t:"ţ",u:"ü",v:"ṽ",w:"ŵ",x:"ẋ",y:"ý",z:"ž"}; + var out=String(s).replace(/(\{[A-Za-z0-9_]+\}|<[^>]*>|&[a-z#0-9]+;)|([A-Za-z])/g,function(x,tieni,l){ + if(tieni) return tieni; + var u=l.toLowerCase(), r=m[u]||l; return l===u ? r : r.toUpperCase(); + }); + var extra=Math.ceil(String(s).length*0.35), tilde=""; + for(var i=0;i.json, nel precache del service worker */ +function i18nCarica(lang){ + if(lang==="it" || lang==="xx" || I18N.dict[lang]) return Promise.resolve(); + if(!I18N.caricando[lang]){ + I18N.caricando[lang]=fetch("/i18n/"+lang+".json",{credentials:"same-origin"}).then(function(r){ + if(!r.ok) throw new Error("i18n "+r.status); + return r.json(); + }).then(function(d){ I18N.dict[lang]=d; }).catch(function(){ I18N.caricando[lang]=null; }); + } + return I18N.caricando[lang]; +} +/* i testi dell'HTML: gli slot sono il testo dell'elemento (data-t) e gli attributi (data-t-title, …) */ +var I18N_SLOT_ATTR=["title","aria-label","placeholder","alt"]; +function i18nNodoTesto(el){ + for(var c=el.firstChild; c; c=c.nextSibling){ if(c.nodeType===3 && /\S/.test(c.nodeValue)) return c; } + return null; +} +function i18nDaSlot(lang,key,it){ + if(lang==="it") return it; + var s=(lang==="xx") ? i18nPseudo(it) : i18nCerca(lang,key); + return s==null ? it : s; +} +function i18nApplica(root){ + var lang=I18N.lang, rad=root||document; + var els=rad.querySelectorAll("[data-t],[data-t-title],[data-t-aria-label],[data-t-placeholder],[data-t-alt]"); + for(var i=0;i-1); + if(!ok) lang="it"; + return i18nCarica(lang).then(function(){ + I18N.lang=(lang==="it" || lang==="xx" || I18N.dict[lang]) ? lang : "it"; + try{ document.documentElement.lang=(I18N.lang==="xx" ? "it" : I18N.lang); }catch(e){} + i18nApplica(); + }); +} +/* avvio: solo con ?lang=en / ?lang=xx. In italiano (tutti gli utenti di oggi) non succede NIENTE, nemmeno una lettura del DOM. */ +(function(){ + var l="it"; + try{ var m=/[?&]lang=([a-z]{2})(?:&|#|$)/.exec(location.search); if(m) l=m[1]; }catch(e){} + if(l==="it") return; + if(l==="xx") I18N.lang="xx"; /* senza file: subito, così anche i testi costruiti da JS partono in pseudo */ + var vai=function(){ i18nImposta(l); }; + if(document.readyState==="loading") document.addEventListener("DOMContentLoaded",vai); else vai(); +})(); + /* ============ GRADIENTI CONDIVISI (materiali realistici) ============ */ var DEFS=''+ ''+ @@ -24635,7 +24766,7 @@ function snapValido(v){ return v==="0"||v==="1"||v==="5"||v==="10"||v==="25"||v= function snapDalDocumento(){ var v=DOC_EXTRA && DOC_EXTRA.snap; snapMode=snapValido(v) ? v : "obj"; try{ syncSnapSelects(); }catch(e){} } /* il menu si allinea quando c'è; aprire il documento non deve mai fallire per lui */ /* Le voci dell'aggancio seguono l'unità del documento (19/11/2026): in piedi 6", 1', 2', 3' (passi esatti, DOC_SNAP_FT), altrimenti 25 cm, 50 cm, 1 m. */ /* Precisione al centimetro (22/11/2026): in testa i passi fini 1, 5, 10 cm (in piedi 1" e 3"); il passo di serie resta 25 cm / 1'. «Libero» = senza griglia (a cm interi nello spostamento, continuo nel ridimensionamento). */ -function snapOpzioni(){ return docUnita()==="ft" ? [["0","Libero"],["ft1","1\""],["ft3","3\""],["ft6","6\""],["ft12","1'"],["ft24","2'"],["ft36","3'"],["obj","Solo oggetti"]] : [["0","Libero"],["1","1 cm"],["5","5 cm"],["10","10 cm"],["25","25 cm"],["50","50 cm"],["100","1 m"],["obj","Solo oggetti"]]; } +function snapOpzioni(){ return docUnita()==="ft" ? [["0",t("barra.libero")],["ft1","1\""],["ft3","3\""],["ft6","6\""],["ft12","1'"],["ft24","2'"],["ft36","3'"],["obj",t("barra.soloOggetti")]] : [["0",t("barra.libero")],["1","1 cm"],["5","5 cm"],["10","10 cm"],["25","25 cm"],["50","50 cm"],["100","1 m"],["obj",t("barra.soloOggetti")]]; } function snapOpzioniScrivi(){ var o=snapOpzioni(), chiave=o.map(function(x){ return x[0]; }).join(","); ["snapSel","snapSelM"].forEach(function(id){ var el=document.getElementById(id); if(!el || el.__snapChiave===chiave) return; el.__snapChiave=chiave; @@ -44751,14 +44882,14 @@ function buildPdfFoglioCambi(d, formato){ } function exportFoglioCambi(){ if(paloTemporaneoAttivo()){ custEditorAvvisa(); return Promise.resolve(false); } - var info=document.getElementById("pdfInfo"); info.className="mstatus"; info.textContent="Genero il foglio dei cambi…"; + var info=document.getElementById("pdfInfo"); info.className="mstatus"; info.textContent=t("esporta.generoFoglioCambi"); return buildPdfFoglioCambi(new Date()).then(function(doc){ pdfSave(doc, cambiFoglioNomeFile()); if(typeof segnaPdfEsportato==="function") segnaPdfEsportato(); - info.className="mstatus ok"; info.textContent="✓ Foglio dei cambi scaricato ("+doc.getNumberOfPages()+(doc.getNumberOfPages()===1?" pagina":" pagine")+")."; + info.className="mstatus ok"; info.textContent=t("esporta.foglioCambiScaricato",{n:doc.getNumberOfPages()}); try{ track("export",{format:"pdf-cambi"}); }catch(_e){} return true; - }).catch(function(e){ info.className="mstatus err"; info.textContent="Errore: "+(e&&e.message||e); return false; }); + }).catch(function(e){ info.className="mstatus err"; info.textContent=t("esporta.errore",{msg:(e&&e.message||e)}); return false; }); } /* «Prima di esportare»: quanti elementi con un microfono entrano nei cambi senza essere nel palco base (la channel list è quella del palco base) */ function cambiMicFuoriLista(){ @@ -46444,8 +46575,8 @@ function pacchettoCrea(){ var N=resolveScale(paper, sel, orient, cartHFor(header, paper, orient)); if(!N && (chiavi.indexOf("stageplot")>=0 || chiavi.indexOf("piantapalco")>=0 || chiavi.indexOf("piantaluci")>=0)){ err.textContent="Il palco non entra nemmeno a 1:500 su "+paper.toUpperCase()+": cambia foglio o area nell'Esporta."; err.hidden=false; return; } var ctx={paper:paper, N:N, orient:orient, header:header, perPagina:(window.__pdfListaFmt && window.__pdfListaFmt.perPagina===48) ? 48 : 32}; - var opz=pacchettoOpzioni(); go.disabled=true; var _t=go.textContent; go.textContent="Genero…"; - pacchettoCostruisci(voci, function(k){ return pacchettoProduci(k, ctx); }, opz, function(v, i, n){ info.hidden=false; info.textContent="Genero "+(i+1)+" di "+n+": "+v.nome+"…"; }) + var opz=pacchettoOpzioni(); go.disabled=true; var _t=go.textContent; go.textContent=t("esporta.generoBreve"); + pacchettoCostruisci(voci, function(k){ return pacchettoProduci(k, ctx); }, opz, function(v, i, n){ info.hidden=false; info.textContent=t("esporta.pacchettoProgresso",{i:i+1, n:n, nome:v.nome}); }) .then(function(r){ pacchettoScarica(r.bytes, r.nome); if(typeof segnaPdfEsportato==="function") segnaPdfEsportato(); try{ track("export",{format:"zip"}); }catch(_e){} @@ -46535,16 +46666,17 @@ function buildPdfPalcoEsterni(paperKey, scaleSel, orientSel){ function exportPalcoEsterni(paperKey, scaleSel, orientSel){ if(paloTemporaneoAttivo()){ custEditorAvvisa(); return Promise.resolve(false); } var info=document.getElementById("pdfInfo"); - info.className="mstatus"; info.textContent="Genero il palco per esterni…"; + info.className="mstatus"; info.textContent=t("esporta.generoPalcoEsterni"); return buildPdfPalcoEsterni(paperKey, scaleSel, orientSel).then(function(doc){ var nome=palcoEsterniNomeFile(); pdfSave(doc, nome); if(typeof segnaPdfEsportato==="function") segnaPdfEsportato(); var m=doc.__palcoEsterni; info.className="mstatus"+(m.cropped?" warn":" ok"); - info.textContent=(m.cropped?"⚠ ":"✓ ")+"Palco per esterni scaricato ("+paperKey.toUpperCase()+" "+(m.orient==="portrait"?"verticale":"orizzontale")+", scala 1:"+m.N+")"+(m.cropped?" — stampata solo la parte centrale che ci sta nel foglio.":"."); + var _o=(m.orient==="portrait" ? t("esporta.orientVerticale") : t("esporta.orientOrizzontale")); + info.textContent=(m.cropped?"⚠ ":"✓ ")+(m.cropped ? t("esporta.palcoEsterniScaricatoParziale",{foglio:paperKey.toUpperCase(), orient:_o, scala:m.N}) : t("esporta.palcoEsterniScaricato",{foglio:paperKey.toUpperCase(), orient:_o, scala:m.N})); try{ track("export",{format:"pdf-palco-esterni"}); }catch(_e){} return true; - }).catch(function(e){ info.className="mstatus err"; info.textContent="Errore: "+(e&&e.message||e); return false; }); + }).catch(function(e){ info.className="mstatus err"; info.textContent=t("esporta.errore",{msg:(e&&e.message||e)}); return false; }); } /* ═══ FOGLIO PER IL TEATRO (16/11/2026, L4.1 della suite produzione) ═══ Il foglio che il direttore di produzione manda al teatro (o al service): sedie con/senza braccioli, sgabelli, leggii, pedane per misura e @@ -46673,14 +46805,14 @@ function buildPdfFoglioTeatro(d){ function exportFoglioTeatro(){ if(paloTemporaneoAttivo()){ custEditorAvvisa(); return Promise.resolve(false); } var info=document.getElementById("pdfInfo"); - info.className="mstatus"; info.textContent="Genero il foglio per il teatro…"; + info.className="mstatus"; info.textContent=t("esporta.generoFoglioTeatro"); return buildPdfFoglioTeatro(new Date()).then(function(doc){ pdfSave(doc, foglioTeatroNomeFile()); if(typeof segnaPdfEsportato==="function") segnaPdfEsportato(); - info.className="mstatus ok"; info.textContent="✓ Foglio per il teatro scaricato ("+doc.getNumberOfPages()+(doc.getNumberOfPages()===1?" pagina":" pagine")+", A4)."; + info.className="mstatus ok"; info.textContent=t("esporta.foglioTeatroScaricato",{n:doc.getNumberOfPages()}); try{ track("export",{format:"pdf-foglio-teatro"}); }catch(_e){} return true; - }).catch(function(e){ info.className="mstatus err"; info.textContent="Errore: "+(e&&e.message||e); return false; }); + }).catch(function(e){ info.className="mstatus err"; info.textContent=t("esporta.errore",{msg:(e&&e.message||e)}); return false; }); } function exportPdf(paperKey, scaleSel, orient, header){ if(paloTemporaneoAttivo()){ custEditorAvvisa(); return Promise.resolve(false); } /* editor «Crea elemento» aperto: lo stato vivo è il palco temporaneo: niente export */ @@ -46693,7 +46825,7 @@ function exportPdf(paperKey, scaleSel, orient, header){ var aTxt=printArea().custom?"L'area di stampa":"Il palco"; if(!N){ info.className="mstatus err"; info.textContent=aTxt+" non entra nemmeno a 1:500 su "+paperKey.toUpperCase()+" "+oTxt+". Prova un foglio più grande, l'altro orientamento o riduci l'area."; return Promise.resolve(false); } /* se a 1:N il disegno sfora il foglio NON è più un errore: si stampa la parte centrale che ci sta, in scala (vedi pdfStageBox) */ - info.className="mstatus"; info.textContent="Genero il PDF…"; + info.className="mstatus"; info.textContent=t("esporta.generoPdf"); /* U2/U3: download AUTOMATICO del browser, niente più selettore "salva con nome" (la finestra extra) */ var _boxChk=pdfStageBox(N, paperKey, orient, cartHFor(header, paperKey, orient)); /* Restituisce la promessa: è l'UNICO modo per sapere quando l'export è davvero finito. Il bottone @@ -46719,7 +46851,7 @@ function exportPdf(paperKey, scaleSel, orient, header){ _ponte.textContent="Manda anche il link al service"; _ponte.addEventListener("click", function(){ document.getElementById("pdfModal").hidden=true; var sh=document.getElementById("bShareHdr"); if(sh) sh.click(); }); info.appendChild(document.createElement("br")); info.appendChild(_ponte); - var _chiudi=document.getElementById("pdfCancel"); if(_chiudi) _chiudi.textContent="Chiudi"; + var _chiudi=document.getElementById("pdfCancel"); if(_chiudi) _chiudi.textContent=t("esporta.chiudi"); if(!invitoSalvaDopoPdf()) maybeLoginNudge(); /* l'invito a salvare (una riga nel piede) prende il posto del toast */ try{ rigaProgettoDopoPdf(); }catch(e){} /* chi ha un account: dove resta il progetto (P2, una volta sola) */ try{ parereSegna("pdf"); }catch(e){} /* il primo PDF accende la domanda di parere nel box (P5) */ @@ -47725,7 +47857,7 @@ function pdfChannelPage(doc, L, paperKey){ pdfQrGenera(giro); }); function _pdfExportModalCore(){ modal.hidden=false; prevIdx=0; - var _ann=document.getElementById("pdfCancel"); if(_ann) _ann.textContent="Annulla"; /* dopo un export era diventato «Chiudi» */ + var _ann=document.getElementById("pdfCancel"); if(_ann) _ann.textContent=t("esporta.annulla"); /* dopo un export era diventato «Chiudi» */ if(window.__pdfAltriChiudi) window.__pdfAltriChiudi(); /* V1: «Altri file» parte sempre chiuso */ invitoSalvaNascondi(); /* l'invito vale per l'export appena fatto: riaprendo la finestra non resta lì */ rigaProgettoNascondi(); /* idem la riga «dove resta il progetto» (P2) */ diff --git a/app/index.html b/app/index.html index d82a8af4..cc7d3e72 100644 --- a/app/index.html +++ b/app/index.html @@ -4742,53 +4742,53 @@ verificarlo. Il rider PDF completo e' gratis; a pagamento c'e' solo la revisione, facoltativa. --> -

— crea gratuitamente stage plot in scala, liste tecniche e rider PDF · revisione professionale facoltativa

- +

— crea gratuitamente stage plot in scala, liste tecniche e rider PDF · revisione professionale facoltativa

+ - - + + - + - - - + + + - + - - - - - - + + + + + + - @@ -4802,21 +4802,21 @@

Richiedi musicistiMusicisti - - - + Richiedi musicistiMusicisti + + +
- - - - - - - - - + + + + + + + + + @@ -4854,24 +4854,24 @@

Nuovo… - - - + + + +
- - + +
-
Disegno di tutto il progetto
+
Disegno di tutto il progetto

- +
@@ -7155,8 +7155,8 @@

Area di stampa