// Match video captions to the language the member already chose with the 🌐 button. // // Deliberately NOT on by default for English. Someone reading English does not want // captions forced over the picture; someone who switched the site to Italian almost // certainly does. So: if their chosen language has a track, show it. Otherwise show // nothing and leave the player's own CC button to do its job. // // Marty + Manson, 2026-09-17. See tools/captions.mjs for how the tracks are built. (function () { function pick() { var lang = ''; try { lang = String(localStorage.getItem('rmc.lang') || '').toLowerCase(); } catch (e) {} var vids = document.querySelectorAll('video'); for (var i = 0; i < vids.length; i++) { var tt = vids[i].textTracks; if (!tt || !tt.length) continue; var wanted = null; for (var j = 0; j < tt.length; j++) { if (tt[j].kind !== 'captions' && tt[j].kind !== 'subtitles') continue; // never leave a stale track showing when the member switches language tt[j].mode = 'disabled'; if (lang && lang !== 'en' && String(tt[j].language || '').toLowerCase() === lang) wanted = tt[j]; } if (wanted) wanted.mode = 'showing'; } } if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', pick); else pick(); // translate.js writes rmc.lang when the member picks a language; re-run so the // captions follow without a reload, and cover players rendered later. window.addEventListener('storage', function (e) { if (!e || e.key === 'rmc.lang') pick(); }); window.RMCCaptions = { refresh: pick }; })();