Add language and theme preferences

This commit is contained in:
seo
2026-06-07 17:54:20 +09:00
parent 4a02f7f354
commit 7af96612ab
5 changed files with 434 additions and 112 deletions
+14 -10
View File
@@ -8,6 +8,10 @@
const pushDisabledStorageKey = 'controlPushDisabled';
let pushAutoRepairRunning = false;
function tr(key, fallback) {
return typeof window.controlT === 'function' ? window.controlT(key) : fallback;
}
function setButton(text, disabled = false, active = false) {
if (!button) return;
button.textContent = text || 'Push';
@@ -34,10 +38,10 @@
async function deviceNameFromUser() {
const promptFn = window.customPrompt || (() => Promise.resolve(null));
const name = await promptFn('등록할 기기 이름을 입력하세요. 한글 2글자 이상이어야 합니다.', {
title: 'Push 등록',
okText: '등록',
placeholder: '휴대폰',
const name = await promptFn(tr('pushDeviceNamePrompt', 'Enter a device name. Korean names require at least 2 Hangul characters.'), {
title: tr('pushRegisterTitle', 'Push Register'),
okText: tr('register', 'Register'),
placeholder: tr('phone', 'Phone'),
autocomplete: 'off',
});
@@ -48,7 +52,7 @@
const trimmed = String(name || '').trim();
if (hangulCount(trimmed) < 2) {
throw new Error('기기 이름은 한글 2글자 이상이어야 합니다.');
throw new Error(tr('pushDeviceNameInvalid', 'Device name must contain at least 2 Hangul characters.'));
}
return trimmed;
@@ -65,7 +69,7 @@
function savedDeviceName() {
const stored = String(localStorage.getItem(pushDeviceNameStorageKey) || '').trim();
return hangulCount(stored) >= 2 ? stored : '자동복구';
return hangulCount(stored) >= 2 ? stored : tr('autoRepair', 'Auto Repair');
}
function urlBase64ToUint8Array(value) {
@@ -290,9 +294,9 @@
async function unsubscribe() {
const confirmFn = window.customConfirm || (() => Promise.resolve(false));
if (!await confirmFn('현재 브라우저의 Push 구독을 삭제할까요?', {
title: 'Push 삭제',
okText: '삭제',
if (!await confirmFn(tr('pushDeletePrompt', 'Delete this browser Push subscription?'), {
title: tr('pushDeleteTitle', 'Delete Push'),
okText: tr('delete', 'Delete'),
danger: true,
})) {
await refreshButton();
@@ -329,7 +333,7 @@
job.catch(error => {
const alertFn = window.customAlert || (() => Promise.resolve());
alertFn(error.message || 'Push failed', {
title: 'Push 오류',
title: tr('pushErrorTitle', 'Push Error'),
danger: true,
});
refreshButton().catch(() => {});