From 54cf1ff7181463fa41aa2e1c6566aa09c44dd3c4 Mon Sep 17 00:00:00 2001 From: shuaiplus <2327005759@qq.com> Date: Sun, 8 Mar 2026 22:24:11 +0800 Subject: [PATCH] feat(i18n): update error messages for device trust operations --- webapp/src/lib/api.ts | 13 +++++++------ webapp/src/lib/i18n.ts | 26 ++++++++++++++++++-------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/webapp/src/lib/api.ts b/webapp/src/lib/api.ts index db51db7..e46a3e9 100644 --- a/webapp/src/lib/api.ts +++ b/webapp/src/lib/api.ts @@ -1,4 +1,5 @@ import { base64ToBytes, bytesToBase64, decryptBw, decryptBwFileData, decryptStr, encryptBw, encryptBwFileData, hkdf, hkdfExpand, pbkdf2 } from './crypto'; +import { t } from './i18n'; import type { AuthorizedDevice, AdminInvite, @@ -748,7 +749,7 @@ export async function getAuthorizedDevices( authedFetch: (input: string, init?: RequestInit) => Promise ): Promise { const resp = await authedFetch('/api/devices/authorized'); - if (!resp.ok) throw new Error('Failed to load authorized devices'); + if (!resp.ok) throw new Error(t('txt_load_devices_failed')); const body = await parseJson>(resp); return body?.data || []; } @@ -758,14 +759,14 @@ export async function revokeAuthorizedDeviceTrust( deviceIdentifier: string ): Promise { const resp = await authedFetch(`/api/devices/authorized/${encodeURIComponent(deviceIdentifier)}`, { method: 'DELETE' }); - if (!resp.ok) throw new Error('Failed to revoke device authorization'); + if (!resp.ok) throw new Error(t('txt_revoke_device_trust_failed')); } export async function revokeAllAuthorizedDeviceTrust( authedFetch: (input: string, init?: RequestInit) => Promise ): Promise { const resp = await authedFetch('/api/devices/authorized', { method: 'DELETE' }); - if (!resp.ok) throw new Error('Failed to revoke all authorized devices'); + if (!resp.ok) throw new Error(t('txt_revoke_all_device_trust_failed')); } export async function deleteAuthorizedDevice( @@ -773,14 +774,14 @@ export async function deleteAuthorizedDevice( deviceIdentifier: string ): Promise { const resp = await authedFetch(`/api/devices/${encodeURIComponent(deviceIdentifier)}`, { method: 'DELETE' }); - if (!resp.ok) throw new Error('Failed to remove device'); + if (!resp.ok) throw new Error(t('txt_remove_device_failed')); } export async function deleteAllAuthorizedDevices( authedFetch: (input: string, init?: RequestInit) => Promise ): Promise { const resp = await authedFetch('/api/devices', { method: 'DELETE' }); - if (!resp.ok) throw new Error('Failed to remove all devices'); + if (!resp.ok) throw new Error(t('txt_remove_all_devices_failed')); } export async function listAdminUsers(authedFetch: (input: string, init?: RequestInit) => Promise): Promise { @@ -973,7 +974,7 @@ async function normalizeFido2Credentials( , enc: Uint8Array, mac: Uint8Array -): Array> | null { +): Promise> | null> { if (!Array.isArray(credentials) || credentials.length === 0) return null; const out: Array> = []; for (const credential of credentials) { diff --git a/webapp/src/lib/i18n.ts b/webapp/src/lib/i18n.ts index 1a75688..0588610 100644 --- a/webapp/src/lib/i18n.ts +++ b/webapp/src/lib/i18n.ts @@ -44,7 +44,7 @@ const messages: Record> = { txt_address_1: "Address 1", txt_address_2: "Address 2", txt_address_3: "Address 3", - txt_all_device_authorizations_revoked: "All device authorizations revoked", + txt_all_device_authorizations_revoked: "All device trust revoked", txt_all_invites_deleted: "All invites deleted", txt_all_items: "All Items", txt_all_sends: "All Sends", @@ -116,9 +116,10 @@ const messages: Record> = { txt_deletion_date: "Deletion Date", txt_deletion_days: "Deletion Days", txt_device: "Device", - txt_device_authorization_revoked: "Device authorization revoked", + txt_device_authorization_revoked: "Device trust revoked", txt_device_management: "Device Management", txt_device_removed: "Device removed", + txt_load_devices_failed: "Failed to load devices", txt_disable_this_send: "Disable this send", txt_disable_totp: "Disable TOTP", txt_disable_totp_failed: "Disable TOTP failed", @@ -312,8 +313,10 @@ const messages: Record> = { txt_revoke_30_day_totp_trust_for_name: "Revoke 30-day TOTP trust for \"{name}\"?", txt_revoke_30_day_totp_trust_from_all_devices: "Revoke 30-day TOTP trust from all devices?", txt_revoke_all_trusted: "Revoke All Trusted", - txt_revoke_all_trusted_devices: "Revoke all trusted devices", - txt_revoke_device_authorization: "Revoke device authorization", + txt_revoke_all_trusted_devices: "Revoke all device trust", + txt_revoke_device_authorization: "Revoke device trust", + txt_revoke_device_trust_failed: "Failed to revoke device trust", + txt_revoke_all_device_trust_failed: "Failed to revoke all device trust", txt_revoke_trust: "Revoke Trust", txt_role: "Role", txt_save: "Save", @@ -390,6 +393,8 @@ const messages: Record> = { txt_unignore: "Unignore", txt_unlocked: "Unlocked", txt_all_devices_removed: "All devices removed", + txt_remove_device_failed: "Failed to remove device", + txt_remove_all_devices_failed: "Failed to remove all devices", txt_update_item_failed: "Update item failed", txt_update_send_failed: "Update send failed", txt_use_recovery_code: "Use Recovery Code", @@ -622,7 +627,7 @@ const zhCNOverrides: Record = { txt_actions: '操作', txt_type: '类型', txt_revoke_all_trusted: '撤销全部受信任设备', - txt_revoke_all_trusted_devices: '撤销所有受信任设备', + txt_revoke_all_trusted_devices: '撤销所有设备信任', txt_revoke_30_day_totp_trust_from_all_devices: '确认撤销所有设备的 30 天 TOTP 信任吗?', txt_revoke_30_day_totp_trust_for_name: '确认撤销“{name}”的 30 天 TOTP 信任吗?', txt_remove_device_name_and_clear_its_2fa_trust: '确认移除设备“{name}”并清除其 2FA 信任吗?', @@ -642,7 +647,7 @@ const zhCNOverrides: Record = { txt_address_1: '地址 1', txt_address_2: '地址 2', txt_address_3: '地址 3', - txt_all_device_authorizations_revoked: '已撤销所有设备授权', + txt_all_device_authorizations_revoked: '已撤销所有设备信任', txt_all_invites_deleted: '已删除所有邀请码', txt_all_sends: '所有发送', txt_android: '安卓', @@ -676,8 +681,9 @@ const zhCNOverrides: Record = { txt_delete_user: '删除用户', txt_deleted_selected_items: '已删除所选项目', txt_deleted_selected_sends: '已删除所选发送', - txt_device_authorization_revoked: '已撤销设备授权', + txt_device_authorization_revoked: '设备信任已撤销', txt_device_removed: '设备已移除', + txt_load_devices_failed: '加载设备失败', txt_disable_totp_failed: '禁用 TOTP 失败', txt_download_failed: '下载失败', txt_edge_browser: 'Edge 浏览器', @@ -745,7 +751,9 @@ const zhCNOverrides: Record = { txt_registration_succeeded_please_sign_in: '注册成功,请登录', txt_remove_device: '移除设备', txt_revoke: '撤销', - txt_revoke_device_authorization: '撤销设备授权', + txt_revoke_device_authorization: '撤销设备信任', + txt_revoke_device_trust_failed: '撤销设备信任失败', + txt_revoke_all_device_trust_failed: '撤销所有设备信任失败', txt_save_profile_failed: '保存资料失败', txt_secret_and_code_are_required: '密钥和代码不能为空', txt_secret_copied: '密钥已复制', @@ -778,6 +786,8 @@ const zhCNOverrides: Record = { txt_unlock_failed_master_password_is_incorrect: '解锁失败,主密码不正确。', txt_unlocked: '已解锁', txt_all_devices_removed: '已移除所有设备', + txt_remove_device_failed: '移除设备失败', + txt_remove_all_devices_failed: '移除所有设备失败', txt_update_item_failed: '更新项目失败', txt_update_send_failed: '更新发送失败', txt_use_your_one_time_recovery_code_to_disable_two_step_verification: '使用一次性恢复代码禁用两步验证。',