/** * nomadro hard-coded zh-CN UI for MiroTalk P2P. * Do NOT rely on Google Translate (often blocked in CN). */ (function nomadroI18n() { 'use strict'; document.documentElement.lang = 'zh-CN'; document.documentElement.classList.add('nomadro-embed'); // Bust stale MiroTalk brand cache that keeps English try { const key = 'brandDataP2P'; const raw = sessionStorage.getItem(key); if (raw && (raw.includes('MiroTalk') || raw.includes('"language":"en"'))) { sessionStorage.removeItem(key); } } catch (_) {} const map = [ ['Join meeting', '进入房间'], ['Enter your email or name', '输入昵称'], ['Please enter your email or name', '请输入昵称'], ['Email must be max 254 char', '邮箱最多 254 个字符'], ['Name must be max 32 char', '昵称最多 32 个字符'], ['Invalid name!', '昵称无效'], ['Username is already in use!', '昵称已被占用'], ['Stop the audio', '关闭麦克风'], ['Stop the video', '关闭摄像头'], ['Start screen sharing', '开始共享屏幕'], ['Toggle screen sharing', '切换屏幕共享'], ['Toggle video mirror', '镜像画面'], ['Leave meeting', '离开'], ['Leave this room', '离开房间'], ['Open the chat', '打开聊天'], ['Show participants', '参与者'], ['Open the settings', '设置'], ['Raise your hand', '举手'], ['Close', '关闭'], ['Send', '发送'], ['Loading', '加载中'], ['Share the room', '分享房间'], ['Copy URL', '复制链接'], ['Email invite', '邮件邀请'], ['Scan to join the room', '扫码加入'], ]; function translateText(s) { if (!s) return s; let out = s; for (const [en, zh] of map) { if (out.includes(en)) out = out.split(en).join(zh); } return out; } function walk(node) { if (!node) return; if (node.nodeType === 3) { const next = translateText(node.nodeValue); if (next !== node.nodeValue) node.nodeValue = next; return; } if (node.nodeType !== 1) return; const tag = node.tagName; if (tag === 'SCRIPT' || tag === 'STYLE' || tag === 'NOSCRIPT') return; if (node.getAttribute) { ['title', 'placeholder', 'aria-label'].forEach((attr) => { const v = node.getAttribute(attr); if (!v) return; const t = translateText(v); if (t !== v) node.setAttribute(attr, t); }); } const kids = node.childNodes; for (let i = 0; i < kids.length; i++) walk(kids[i]); } function sweep() { walk(document.body); // SweetAlert titles / buttons document.querySelectorAll('.swal2-title, .swal2-confirm, .swal2-cancel, .swal2-html-container, .swal2-input').forEach((el) => { if (el.tagName === 'INPUT') { const p = el.getAttribute('placeholder'); if (p) el.setAttribute('placeholder', translateText(p)); return; } const t = translateText(el.textContent); if (t !== el.textContent) el.textContent = t; }); } document.addEventListener('DOMContentLoaded', () => { document.body && document.body.classList.add('nomadro-embed'); sweep(); const obs = new MutationObserver(() => sweep()); obs.observe(document.documentElement, { childList: true, subtree: true, characterData: true }); }); })();