Triple Play training video (2:40, Marty's voice) with captions in en/it/fr/es/de/pt on /training and /how-pay-works; four-person reality added to the page, chatbot and AI prompt; captions.mjs gains --dump/--tr-dir for hand translations while the site translator is down

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-14 17:37:00 -05:00
parent 9c892d4b12
commit 3f48f6848f
42 changed files with 1444 additions and 32 deletions
+11
View File
@@ -75,6 +75,8 @@ for (const w of words) {
if (cur) sentences.push(cur);
for (const s of sentences) s.text = s.words.map(w => w.text).join(' ').replace(/\s+([,.!?;:])/g, '$1').trim();
console.log('sentences: ' + sentences.length);
// --dump <file>: write the English sentence list (the unit to translate by hand for --tr-dir) and stop
{ const i = process.argv.indexOf('--dump'); if (i > 0) { fs.writeFileSync(process.argv[i + 1], JSON.stringify(sentences.map(s => s.text), null, 1)); console.log('dumped to ' + process.argv[i + 1]); process.exit(0); } }
// ---------- 3. sentence -> cues, splitting only where a sentence is too long to show ----------
function wrap(text) {
@@ -130,7 +132,16 @@ fs.writeFileSync(path.join(OUT, base + '.en.vtt'), toVtt(cues));
console.log('wrote ' + base + '.en.vtt');
// ---------- 4. translate whole sentences, then lay them back over the same timings ----------
// --tr-dir <dir>: hand-made translations, one <dir>/<lang>.json per language holding an array that matches the
// sentence list (write it with --dump). Used when the site translator is down (2026-10-14: OpenRouter key at its limit).
const TR_DIR = (() => { const i = process.argv.indexOf('--tr-dir'); return i > 0 ? process.argv[i + 1] : ''; })();
async function translate(texts, tl) {
if (TR_DIR) {
const f = path.join(TR_DIR, tl + '.json');
const arr = JSON.parse(fs.readFileSync(f, 'utf8'));
if (!Array.isArray(arr) || arr.length !== texts.length) { console.error('REFUSING ' + tl + ': ' + f + ' has ' + (arr.length || 0) + ' entries, need ' + texts.length); process.exit(1); }
return arr;
}
const out = [];
for (let i = 0; i < texts.length; i += 20) {
const batch = texts.slice(i, i + 20).map(t => t.slice(0, 300));