| 1 | import type { BrowserDownloadState } from "./browserHost"; |
| 2 | import { useI18n, type Locale } from "./i18n"; |
| 3 | |
| 4 | // Panel copy stays inside the lazy browser chunk: the shared dictionaries are |
| 5 | // ratcheted per locale chunk (check-bundle-budget) and this surface only |
| 6 | // exists in the Electron shell. |
| 7 | const en = { |
| 8 | panel: "Browser", |
| 9 | tabs: "Browser tabs", |
| 10 | newTab: "New tab from address", |
| 11 | untitled: "Untitled", |
| 12 | temporary: "Temporary", |
| 13 | loading: "Loading", |
| 14 | closeTab: (title: string) => `Close ${title}`, |
| 15 | address: "Address", |
| 16 | addressPlaceholder: "Enter an address", |
| 17 | back: "Back", |
| 18 | forward: "Forward", |
| 19 | reload: "Reload", |
| 20 | stop: "Stop loading", |
| 21 | zoomIn: "Zoom in", |
| 22 | zoomOut: "Zoom out", |
| 23 | zoomReset: (percent: number) => `Reset zoom (${percent}%)`, |
| 24 | devTools: "Toggle DevTools", |
| 25 | takeover: "You are controlling this page; the agent is paused", |
| 26 | takeControl: "Take over", |
| 27 | resume: "Resume", |
| 28 | errorTitle: "This page could not be loaded", |
| 29 | errorDetail: (code: number, description: string) => `${description} (${code})`, |
| 30 | retry: "Retry", |
| 31 | emptyTitle: "No pages open", |
| 32 | emptyHint: "Enter an address to open a page for this task.", |
| 33 | downloads: "Downloads", |
| 34 | clearDownloads: "Clear finished downloads", |
| 35 | downloadState: { |
| 36 | progressing: "Downloading", |
| 37 | completed: "Completed", |
| 38 | cancelled: "Cancelled", |
| 39 | interrupted: "Failed", |
| 40 | } satisfies Record<BrowserDownloadState, string>, |
| 41 | actionFailed: (message: string) => `Browser: ${message}`, |
| 42 | }; |
| 43 | |
| 44 | export type BrowserCopy = typeof en; |
| 45 | |
| 46 | const zh: BrowserCopy = { |
| 47 | panel: "浏览器", |
| 48 | tabs: "浏览器标签页", |
| 49 | newTab: "用地址栏内容新建标签页", |
| 50 | untitled: "未命名", |
| 51 | temporary: "临时", |
| 52 | loading: "加载中", |
| 53 | closeTab: (title) => `关闭 ${title}`, |
| 54 | address: "地址", |
| 55 | addressPlaceholder: "输入网址", |
| 56 | back: "后退", |
| 57 | forward: "前进", |
| 58 | reload: "重新加载", |
| 59 | stop: "停止加载", |
| 60 | zoomIn: "放大", |
| 61 | zoomOut: "缩小", |
| 62 | zoomReset: (percent) => `重置缩放(${percent}%)`, |
| 63 | devTools: "开关开发者工具", |
| 64 | takeover: "你正在操作此页面;代理已暂停", |
| 65 | takeControl: "接管", |
| 66 | resume: "恢复", |
| 67 | errorTitle: "无法加载此页面", |
| 68 | errorDetail: (code, description) => `${description}(${code})`, |
| 69 | retry: "重试", |
| 70 | emptyTitle: "没有打开的页面", |
| 71 | emptyHint: "输入网址,为当前任务打开页面。", |
| 72 | downloads: "下载", |
| 73 | clearDownloads: "清除已完成的下载", |
| 74 | downloadState: { progressing: "下载中", completed: "已完成", cancelled: "已取消", interrupted: "失败" }, |
| 75 | actionFailed: (message) => `浏览器:${message}`, |
| 76 | }; |
| 77 | |
| 78 | const zhTW: BrowserCopy = { |
| 79 | panel: "瀏覽器", |
| 80 | tabs: "瀏覽器分頁", |
| 81 | newTab: "以網址列內容新增分頁", |
| 82 | untitled: "未命名", |
| 83 | temporary: "暫時", |
| 84 | loading: "載入中", |
| 85 | closeTab: (title) => `關閉 ${title}`, |
| 86 | address: "網址", |
| 87 | addressPlaceholder: "輸入網址", |
| 88 | back: "上一頁", |
| 89 | forward: "下一頁", |
| 90 | reload: "重新載入", |
| 91 | stop: "停止載入", |
| 92 | zoomIn: "放大", |
| 93 | zoomOut: "縮小", |
| 94 | zoomReset: (percent) => `重設縮放(${percent}%)`, |
| 95 | devTools: "切換開發人員工具", |
| 96 | takeover: "你正在操作此頁面;代理已暫停", |
| 97 | takeControl: "接管", |
| 98 | resume: "繼續", |
| 99 | errorTitle: "無法載入此頁面", |
| 100 | errorDetail: (code, description) => `${description}(${code})`, |
| 101 | retry: "重試", |
| 102 | emptyTitle: "沒有開啟的頁面", |
| 103 | emptyHint: "輸入網址,為目前任務開啟頁面。", |
| 104 | downloads: "下載", |
| 105 | clearDownloads: "清除已完成的下載", |
| 106 | downloadState: { progressing: "下載中", completed: "已完成", cancelled: "已取消", interrupted: "失敗" }, |
| 107 | actionFailed: (message) => `瀏覽器:${message}`, |
| 108 | }; |
| 109 | |
| 110 | export function browserCopy(locale: Locale): BrowserCopy { |
| 111 | return locale === "zh" ? zh : locale === "zh-TW" ? zhTW : en; |
| 112 | } |
| 113 | |
| 114 | export function useBrowserCopy(): BrowserCopy { |
| 115 | return browserCopy(useI18n().locale); |
| 116 | } |
| 117 |