/** Helpers i18n — langue UI Chrome (chrome.i18n.getUILanguage). */ function t(key, ...subs) { const msg = chrome.i18n.getMessage(key, subs) return msg || key } function uiLocaleTag() { return (chrome.i18n.getUILanguage() || 'en').replace('_', '-').split('-')[0] } function isUiRtl() { return ['ar', 'fa', 'he', 'ur'].includes(uiLocaleTag()) } function applyDocumentLocale() { const lang = uiLocaleTag() document.documentElement.lang = lang document.documentElement.dir = isUiRtl() ? 'rtl' : 'ltr' document.body?.classList.toggle('ui-rtl', isUiRtl()) } function applyShellI18n() { document.title = t('extName') const brandSub = document.querySelector('.brand-sub') if (brandSub) brandSub.textContent = t('webClipper') if (typeof els !== 'undefined' && els.connLabel) { els.connLabel.textContent = t('connected') } if (typeof els !== 'undefined' && els.settingsBtn) { els.settingsBtn.title = t('instanceSettings') els.settingsBtn.setAttribute('aria-label', t('instanceSettings')) } const urlLabel = document.getElementById('instanceUrlLabel') || document.querySelector('#settingsPanel .field > span') if (urlLabel) urlLabel.textContent = t('instanceUrlLabel') const presetProd = document.querySelector('[data-url="https://memento-note.com"]') if (presetProd) presetProd.textContent = t('presetProduction') if (typeof els !== 'undefined' && els.applyInstanceBtn) { els.applyInstanceBtn.textContent = t('applyReconnect') } if (typeof els !== 'undefined' && els.openLoginBtn) { els.openLoginBtn.textContent = `${t('openMomento')} ↗` } const hint = document.querySelector('.settings-hint') if (hint) hint.textContent = t('settingsHint') const footer = document.querySelector('.footer-meta') if (footer) footer.textContent = t('footerVersion') }