feat(host-control-mode): localize the in-page dialog & badge

The host-control desync dialog and the "watching on your own" badge were
hardcoded English — content.js has no i18n loader. Background does, so it now
resolves the strings (GET_HCM_STRINGS: loadLocale + getMessage) and content
fetches them on init with English fallbacks, re-rendering the badge if it was
already shown. The dialog body is now generic (dropped the paused/jumped verb)
to keep translation clean across languages.

Adds 6 keys (HCM_DIALOG_TITLE/BODY/STAY/SOLO, HCM_BADGE_SOLO/RESYNC) translated
across all 15 popup locales.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
KoalaDev
2026-06-26 16:26:31 +02:00
parent 95ff460856
commit bb030a9737
18 changed files with 131 additions and 8 deletions
+14
View File
@@ -1731,6 +1731,20 @@ async function handleAsyncMessage(message, sender, sendResponse) {
} else if (message.type === 'REQUEST_HOST_SYNC') {
// content.js resync: hand back the host's extrapolated current position.
sendResponse({ target: getHostSyncTarget() });
} else if (message.type === 'GET_HCM_STRINGS') {
// Localized strings for the in-page host-control dialog/badge. content.js
// has no i18n loader of its own, so background resolves them here.
const settings = await chrome.storage.local.get(['locale']);
const lang = settings.locale || getSystemLanguage();
await loadLocale(lang);
sendResponse({
title: getMessage('HCM_DIALOG_TITLE'),
body: getMessage('HCM_DIALOG_BODY'),
stay: getMessage('HCM_DIALOG_STAY'),
solo: getMessage('HCM_DIALOG_SOLO'),
badge: getMessage('HCM_BADGE_SOLO'),
resync: getMessage('HCM_BADGE_RESYNC')
});
} else if (message.type === 'HCM_DESYNC_STATE') {
// content.js tells us whether the local user chose to watch on their own.
// Only accept from the currently selected tab.