From d5dd8afbb4e001f07a87dcd759eb19ea50c330f9 Mon Sep 17 00:00:00 2001 From: Riko Date: Thu, 8 Oct 2026 19:22:26 -0700 Subject: [PATCH 1/2] Simplify settings copy in English and Chinese --- README.md | 2 +- README.zh-CN.md | 2 +- Sources/SayoApp/SayoApp.swift | 22 +- Sources/SayoCore/DiagnosticAnalysis.swift | 22 +- Sources/SayoCore/Settings.swift | 5 +- Sources/SayoUI/AboutAuthorView.swift | 15 +- Sources/SayoUI/AppUpdateView.swift | 34 +-- Sources/SayoUI/AppViewModel.swift | 48 ++-- .../ApplicationFilterSettingsView.swift | 28 +-- Sources/SayoUI/DiagnosticAnalysisView.swift | 64 +++--- Sources/SayoUI/ModelConnectionTestView.swift | 22 +- Sources/SayoUI/ModelProfileEditorView.swift | 66 +++--- Sources/SayoUI/OnboardingView.swift | 4 +- Sources/SayoUI/SayoDesignSystem.swift | 12 +- Sources/SayoUI/SettingsView.swift | 217 +++++++++--------- Tests/SayoUITests/AppUpdateModelTests.swift | 12 +- updates/plain-settings-copy-20261008.json | 5 + 17 files changed, 276 insertions(+), 304 deletions(-) create mode 100644 updates/plain-settings-copy-20261008.json diff --git a/README.md b/README.md index 8fc2e5f..2800ceb 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Press `Option+E` in another app's input field to get started. ## Features - **In-place translation and polishing**: Handle mixed Chinese and English text, translation, and tone adjustments. Process selected text, or the entire input field by default when nothing is selected. -- **Preview or replace directly**: Preview results in manual mode, or rewrite directly with a keyboard shortcut in silent mode. +- **Preview or replace directly**: Use Click to rewrite to preview results, or Replace directly to rewrite and replace text with a keyboard shortcut. - **Two target languages**: Assign two shortcuts to rewrite text in two different languages. - **Terminal and CLI**: Supports zsh, bash 4+, fish, and external editor integrations for Codex CLI, Claude Code, and more. diff --git a/README.zh-CN.md b/README.zh-CN.md index 0367db5..53544cc 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -46,7 +46,7 @@ brew upgrade --cask --greedy riko2chen/sayo/sayo ## 功能 - **原地翻译与润色**:处理中英混输、翻译和语气调整;有选区时处理选中文字,无选区时默认处理整个输入框。 -- **预览或直接替换**:手动模式先查看结果,静默模式通过快捷键直接改写。 +- **预览或直接替换**:“点击改写”可先查看结果,“直接替换”通过快捷键改写并替换原文。 - **双目标语言**:支持绑定两个快捷键,分别转写成两种不同语言。 - **终端与 CLI**:支持 zsh、bash 4+、fish,以及 Codex CLI、Claude Code 等外部编辑器接入。 diff --git a/Sources/SayoApp/SayoApp.swift b/Sources/SayoApp/SayoApp.swift index 19afec9..c17567f 100644 --- a/Sources/SayoApp/SayoApp.swift +++ b/Sources/SayoApp/SayoApp.swift @@ -403,8 +403,7 @@ public enum SayoRuntime { try self.registerShortcuts(settings) self.coordinator.configureShortcutBehavior(settings) self.model.notice = self.localized( - "Working mode updated.", - "工作模式已更新。" + "Rewrite mode updated.", "操作方式已更新。" ) self.model.noticeIsError = false } catch { @@ -860,8 +859,8 @@ public enum SayoRuntime { let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 660, height: 680), styleMask: [.titled, .closable, .miniaturizable, .resizable], backing: .buffered, defer: false) - window.title = localized(session.isNew ? "Add model" : "Edit model", - session.isNew ? "新增模型" : "编辑模型") + window.title = localized(session.isNew ? "Add service" : "Edit service", + session.isNew ? "添加服务" : "编辑服务") window.identifier = .init("sayo.model-editor") window.minSize = NSSize(width: 620, height: 630) window.titlebarAppearsTransparent = true @@ -886,14 +885,14 @@ public enum SayoRuntime { let text = try text ?? DiagnosticLog.shared.recentText(limit: Int.max) let panel = NSSavePanel() panel.nameFieldStringValue = "sayo-diagnostics.jsonl" - panel.title = localized("Export diagnostic logs", "导出诊断日志") + panel.title = localized("Export records", "导出记录") panel.canCreateDirectories = true guard let settingsWindow else { return } panel.beginSheetModal(for: settingsWindow) { [weak self] response in guard let self, response == .OK, let url = panel.url else { return } do { try text.write(to: url, atomically: true, encoding: .utf8) - self.model.notice = self.localized("Logs exported to \(url.path)", "日志已导出到 \(url.path)") + self.model.notice = self.localized("Records exported.\n\(url.path)", "记录已导出。\n\(url.path)") self.model.noticeIsError = false } catch { self.model.notice = error.localizedDescription; self.model.noticeIsError = true } } @@ -927,14 +926,14 @@ public enum SayoRuntime { filenameDate.locale = Locale(identifier: "en_US_POSIX") filenameDate.dateFormat = "yyyyMMdd-HHmmss" panel.nameFieldStringValue = "sayo-ai-diagnosis-\(filenameDate.string(from: Date())).txt" - panel.title = localized("Save AI diagnosis", "保存 AI 自诊断结果") + panel.title = localized("Save result", "保存结果") panel.canCreateDirectories = true guard let settingsWindow else { return } panel.beginSheetModal(for: settingsWindow.attachedSheet ?? settingsWindow) { [weak self] response in guard let self, response == .OK, let url = panel.url else { return } do { try report.write(to: url, atomically: true, encoding: .utf8) - self.model.notice = self.localized("Diagnosis saved to \(url.path)", "诊断结果已保存到 \(url.path)") + self.model.notice = self.localized("Troubleshooting result saved.\n\(url.path)", "排查结果已保存。\n\(url.path)") self.model.noticeIsError = false } catch { self.model.notice = error.localizedDescription @@ -959,11 +958,10 @@ public enum SayoRuntime { private func confirmDiscardModelChanges() -> Bool { let alert = NSAlert() - alert.messageText = localized("Discard unsaved model changes?", "放弃未保存的模型更改?") - alert.informativeText = localized("Changes in this window will not be saved.", - "此窗口中的更改不会保存。") + alert.messageText = localized("Discard changes?", "放弃修改") + alert.informativeText = localized("Your changes have not been saved.", "当前修改尚未保存。") alert.addButton(withTitle: localized("Keep editing", "继续编辑")) - alert.addButton(withTitle: localized("Discard changes", "放弃更改")) + alert.addButton(withTitle: localized("Discard changes", "放弃修改")) alert.alertStyle = .warning return alert.runModal() == .alertSecondButtonReturn } diff --git a/Sources/SayoCore/DiagnosticAnalysis.swift b/Sources/SayoCore/DiagnosticAnalysis.swift index 913c66e..a4044a0 100644 --- a/Sources/SayoCore/DiagnosticAnalysis.swift +++ b/Sources/SayoCore/DiagnosticAnalysis.swift @@ -143,10 +143,10 @@ public enum DiagnosticCategory: String, CaseIterable, Sendable { case invocation, input, system, history public func title(_ language: InterfaceLanguage) -> String { switch self { - case .invocation: return language.text("Invocations", "唤起记录") - case .input: return language.text("Input observations", "输入观察") - case .system: return language.text("System", "系统事件") - case .history: return language.text("Unlinked history", "历史未关联记录") + case .invocation: return language.text("Rewrite records", "改写记录") + case .input: return language.text("Input checks", "输入检查") + case .system: return language.text("App activity", "运行记录") + case .history: return language.text("Older records", "旧记录") } } } @@ -179,15 +179,15 @@ public struct DiagnosticGroup: Identifiable, Equatable, Sendable { public var fallbackReason: String? { events.last(where: { $0.event == "fallback_started" })?.fields["reason"] } public func summary(_ language: InterfaceLanguage) -> String { switch outcome { - case "inserted_at_caret": return language.text("Inserted at caret", "已追加,原文保留") - case "replaced": return language.text("Replaced successfully", "已成功替换") + case "inserted_at_caret": return language.text("Result inserted. Original kept.", "结果已插入,原文保留。") + case "replaced": return language.text("Original replaced.", "原文已替换。") case "failed": return language.text("Failed", "操作失败") case "cancelled": return language.text("Cancelled", "已取消") - case "ignored": return language.text("Skipped", "未触发改写") - case "ready": return language.text("Result ready; not yet applied", "结果已就绪,尚未应用") - case "loading": return language.text("Request started; no completion recorded", "已发起请求,尚无完成记录") - case "dispatched": return language.text("Shortcut sent; replacement not confirmed here", "快捷键已发送,此记录尚未确认替换") - default: return category == .invocation ? language.text("No outcome recorded", "暂无结果记录") : language.text("\(events.count) events", "\(events.count) 条事件") + case "ignored": return language.text("No rewrite was started.", "本次未开始改写。") + case "ready": return language.text("Result ready. Original not replaced yet.", "已生成结果,尚未替换。") + case "loading": return language.text("Processing started. No completion recorded.", "已开始处理,暂无完成记录。") + case "dispatched": return language.text("Shortcut sent. Replacement not confirmed.", "已发送按键,尚未确认替换。") + default: return category == .invocation ? language.text("No result recorded.", "暂无结果记录。") : language.text("\(events.count) events", "\(events.count) 条事件") } } } diff --git a/Sources/SayoCore/Settings.swift b/Sources/SayoCore/Settings.swift index cda8e53..243ec87 100644 --- a/Sources/SayoCore/Settings.swift +++ b/Sources/SayoCore/Settings.swift @@ -57,7 +57,7 @@ public extension SayoError { case .permissionRequired: return language.text("Enable Accessibility for Sayo in System Settings.", "请在系统设置中为 Sayo 启用辅助功能权限。") case .missingConfiguration: - return language.text("Add your model and API key in Settings → Language Model.", "请在设置 → 语言模型中配置模型和 API Key。") + return language.text("Open Text services in Settings.\nAdd a service and enter your key.", "请在设置中打开“翻译服务”。\n添加服务并填写密钥。") case .invalidResponse: return language.text("The model returned no usable text. Please try again.", "模型没有返回可用文本,请重试。") case .network(let message): @@ -312,8 +312,7 @@ public struct TranslationShortcutConflict: LocalizedError { public var language: InterfaceLanguage public var errorDescription: String? { language.text( - "Choose a second-language shortcut different from Invoke, Copy, and Replace.", - "第二语言快捷键不能与唤起、复制或替换快捷键相同。" + "The other-language shortcut must differ from rewrite, copy, and replace shortcuts.", "另一语言的按键不能与其他操作相同。" ) } } diff --git a/Sources/SayoUI/AboutAuthorView.swift b/Sources/SayoUI/AboutAuthorView.swift index 420f044..5770949 100644 --- a/Sources/SayoUI/AboutAuthorView.swift +++ b/Sources/SayoUI/AboutAuthorView.swift @@ -16,8 +16,7 @@ struct AboutAuthorView: View { .foregroundStyle(SayoStyle.muted) Text("@Riko") .font(.system(size: 20, weight: .semibold)) - Text(t("Follow along for new tools and updates, or get in touch by email.", - "关注新工具与更新,也欢迎通过邮箱交流。")) + Text(t("Follow new tools and updates, or get in touch by email.", "关注新工具,也欢迎来信交流。")) .font(.system(size: 12)).foregroundStyle(SayoStyle.muted) .fixedSize(horizontal: false, vertical: true) } @@ -28,13 +27,13 @@ struct AboutAuthorView: View { symbol: "envelope", trailingSymbol: "chevron.right") } .accessibilityIdentifier("author-email") - .accessibilityHint(t("Show and copy the email address", "查看并复制邮箱地址")) + .accessibilityHint(t("View and copy the email address.", "查看并复制邮箱。")) .popover(isPresented: $showingEmail, arrowEdge: .top) { emailPopover } contactDivider - contactLink(t("Project homepage", "项目主页"), detail: "sayo.rikolab.com", + contactLink(t("Official website", "官方网站"), detail: "sayo.rikolab.com", symbol: "globe", url: "https://sayo.rikolab.com/", identifier: "author-homepage") contactDivider - contactLink(t("Source code", "源代码"), detail: "GitHub · riko2chen/Sayo", + contactLink(t("View source", "查看源码"), detail: "GitHub · riko2chen/Sayo", symbol: "chevron.left.forwardslash.chevron.right", url: "https://github.com/riko2chen/Sayo", identifier: "author-github") contactDivider @@ -88,7 +87,7 @@ struct AboutAuthorView: View { contactRow(title, detail: detail, symbol: symbol) } .accessibilityIdentifier(identifier) - .accessibilityHint(t("Open in your browser", "在浏览器中打开")) + .accessibilityHint(t("Open in your browser.", "用浏览器打开。")) } private var emailPopover: some View { @@ -96,7 +95,7 @@ struct AboutAuthorView: View { VStack(alignment: .leading, spacing: 6) { Text(t("Email the author", "联系作者")) .font(.system(size: 15, weight: .semibold)) - Text(t("Feedback, ideas, or just a hello.", "反馈、建议,或只是打个招呼。")) + Text(t("Share an idea, report a problem, or say hello.", "提建议、报问题,或打个招呼。")) .font(.system(size: 12)).foregroundStyle(SayoStyle.muted) } Text(email) @@ -110,7 +109,7 @@ struct AboutAuthorView: View { NSPasteboard.general.clearContents() copiedEmail = NSPasteboard.general.setString(email, forType: .string) } label: { - Label(copiedEmail ? t("Copied", "已复制") : t("Copy email address", "复制邮箱地址"), + Label(copiedEmail ? t("Copied", "已复制") : t("Copy email", "复制邮箱"), systemImage: copiedEmail ? "checkmark" : "doc.on.doc") .frame(maxWidth: .infinity) } diff --git a/Sources/SayoUI/AppUpdateView.swift b/Sources/SayoUI/AppUpdateView.swift index ae86446..9e263a4 100644 --- a/Sources/SayoUI/AppUpdateView.swift +++ b/Sources/SayoUI/AppUpdateView.swift @@ -4,20 +4,20 @@ import SayoCore extension AppViewModel { public var updateActionTitle: String { switch updateState { - case .notConfigured: return text("Updates Unavailable", "更新不可用") - case .checking: return text("Checking for Updates…", "检查更新中") - case .available: return text("Download Update", "下载更新") + case .notConfigured: return text("Unavailable", "暂不可用") + case .checking: return text("Checking", "检查中") + case .available: return text("Download update", "下载新版") case .information: return text("View Update", "查看更新") case .downloading(_, let progress): let title = text("Downloading", "下载中") if let progress { return "\(title) \(progress.formatted(.percent.precision(.fractionLength(0))))" } return "\(title)…" - case .preparing: return text("Preparing…", "正在准备…") - case .readyToInstall: return text("Update Now", "点击更新") - case .installing: return text("Updating…", "正在更新…") - case .failed: return text("Update Failed · Retry", "更新失败 · 重试") - case .unavailable: return text("Update Unavailable · Retry", "更新不可用 · 重试") - case .upToDate: return text("Up to Date", "已是最新版本") + case .preparing: return text("Preparing", "准备中") + case .readyToInstall: return text("Update now", "立即更新") + case .installing: return text("Updating", "更新中") + case .failed: return text("Retry update", "重试更新") + case .unavailable: return text("Check again", "重新检查") + case .upToDate: return text("Up to date", "已是最新") case .ready: return text("Check for Updates", "检查更新") } } @@ -27,15 +27,15 @@ extension AppViewModel { case .notConfigured: return text("The update service is not available yet.", "更新服务尚未开放。") case .ready: return text("Check for a newer version of Sayo.", "检查是否有新版 Sayo。") case .checking: return text("Looking for a new version of Sayo…", "正在检查新版 Sayo…") - case .available(let version): return text("Sayo \(version) is available to download.", "Sayo \(version) 已发布,可以下载更新。") - case .information(let version): return text("Learn more about Sayo \(version).", "查看 Sayo \(version) 的更新信息。") - case .downloading(let version, _): return text("Downloading Sayo \(version). You can keep using Sayo.", "正在下载 Sayo \(version),你可以继续使用 Sayo。") - case .preparing(let version): return text("Verifying and preparing Sayo \(version)…", "正在验证并准备 Sayo \(version)…") - case .readyToInstall(let version): return text("Sayo \(version) is downloaded. Update and restart now, or install when you quit Sayo.", "Sayo \(version) 已下载。点击更新并重新启动,或在退出 Sayo 时安装。") - case .installing: return text("Sayo will restart to complete the update.", "Sayo 将重新启动以完成更新。") - case .upToDate: return text("You’re using the latest version of Sayo.", "你使用的已是最新版本的 Sayo。") + case .available(let version): return text("Version \(version) is ready to download.", "新版 \(version) 可以下载。") + case .information(let version): return text("See what's new in \(version).", "查看 \(version) 的更新内容。") + case .downloading(let version, _): return text("Downloading \(version).\nYou can keep using Sayo.", "正在下载 \(version)。\n你可以继续使用。") + case .preparing(let version): return text("Checking and preparing \(version)…", "正在检查并准备 \(version)…") + case .readyToInstall(let version): return text("Version \(version) is downloaded.\nUpdate now to restart Sayo.\nOr install when you quit.", "新版 \(version) 已下载。\n立即更新会重新启动应用。\n也可在退出时安装。") + case .installing: return text("Sayo will restart to finish updating.", "应用将重启,完成更新。") + case .upToDate: return text("You are using the latest version.", "你正在使用最新版本。") case .unavailable(let message): return message - case .failed(let message): return text("Couldn’t check or complete the update. \(message)", "无法检查或完成更新。\(message)") + case .failed(let message): return text("Could not check or finish updating.\n\(message)", "无法检查或完成更新。\n\(message)") } } } diff --git a/Sources/SayoUI/AppViewModel.swift b/Sources/SayoUI/AppViewModel.swift index dec9d7d..b06cfe8 100644 --- a/Sources/SayoUI/AppViewModel.swift +++ b/Sources/SayoUI/AppViewModel.swift @@ -84,7 +84,7 @@ public struct ModelProfileOption: Identifiable, Equatable { try action(program, key) cliShortcutDrafts[program] = key ?? "" if let value = try loadCLIShortcutAction?(program) { cliShortcutDrafts[program] = value } - notice = text("CLI shortcut saved; restart the CLI and open a new terminal tab for Codex.", "CLI 快捷键已保存;请重启 CLI,Codex 还需打开新终端标签页。") + notice = text("Shortcut saved. Restart the tool.\nFor Codex, also open a new terminal tab.", "按键已保存,请重启对应工具。\nCodex 还需新开终端标签页。") noticeIsError = false } catch { notice = error.localizedDescription; noticeIsError = true } } @@ -230,11 +230,10 @@ public struct ModelProfileOption: Identifiable, Equatable { formatter.timeZone = .current formatter.dateFormat = "HH:mm:ss ZZZZZ" let time = formatter.string(from: Date()) - diagnosticStatus = text("Refreshed \(time) · Newest first · Local time", "已刷新 \(time) · 最新在上 · 本地时间") + diagnosticStatus = text("Refreshed: \(time)\nLocal time. Newest first.", "已刷新:\(time)\n按本地时间显示,最新在上。") return true } catch { - diagnosticStatus = text("Refresh failed; showing the previous snapshot: \(error.localizedDescription)", - "刷新失败,当前仍为上次内容:\(error.localizedDescription)") + diagnosticStatus = text("Refresh failed. Showing the previous records.\n\(error.localizedDescription)", "刷新失败,仍显示上次内容。\n\(error.localizedDescription)") return false } } @@ -254,9 +253,8 @@ public struct ModelProfileOption: Identifiable, Equatable { aiDiagnosticCandidates = evidence aiDiagnosticSelectedCases = Set(evidence.failures.indices) aiDiagnosticStatus = evidence.isEmpty - ? text("No failed cases were found in the past 30 minutes.", "过去 30 分钟内没有找到失败案例。") - : text("Found \(evidence.failures.count) failed case(s). Select the cases to analyze.", - "找到 \(evidence.failures.count) 个失败案例,请选择需要分析的案例。") + ? text("No failed cases in the last 30 minutes.", "近 30 分钟没有失败记录。") + : text("Found \(evidence.failures.count) failed attempts.\nSelect the records to analyze.", "找到 \(evidence.failures.count) 条失败记录。\n请选择要分析的记录。") } public func selectAIDiagnosticCase(_ index: Int, selected: Bool) { @@ -290,8 +288,7 @@ public struct ModelProfileOption: Identifiable, Equatable { aiDiagnosticResult = ""; aiDiagnosticEvidence = source aiDiagnosticFailureCount = evidence.failures.count aiDiagnosticStatus = text( - "Sending \(evidence.failures.count) redacted failed case(s) to the configured model…", - "正在将 \(evidence.failures.count) 个脱敏失败案例发送给已配置的模型…" + "Sending \(evidence.failures.count) selected records to your service…\nSensitive details are hidden.", "正在发送 \(evidence.failures.count) 条所选记录…\n敏感信息已隐藏。" ) aiDiagnosticTask = Task { [weak self] in guard let self else { return } @@ -303,15 +300,13 @@ public struct ModelProfileOption: Identifiable, Equatable { guard !trimmed.isEmpty else { throw SayoError.invalidResponse } self.aiDiagnosticResult = DiagnosticRedaction.text(trimmed, secrets: secrets) self.aiDiagnosticStatus = self.text( - "AI diagnosis completed from \(evidence.failures.count) failed case(s).", - "AI 自诊断已完成,共分析 \(evidence.failures.count) 个失败案例。" + "Analysis complete: \(evidence.failures.count) records checked.", "排查已完成,分析了 \(evidence.failures.count) 条记录。" ) self.aiDiagnosticRunning = false } catch { guard !Task.isCancelled, token == self.aiDiagnosticGeneration else { return } self.aiDiagnosticStatus = self.text( - "AI diagnosis failed: \(error.localizedDescription)", - "AI 自诊断失败:\(error.localizedDescription)" + "Analysis failed.\n\(error.localizedDescription)", "排查失败。\n\(error.localizedDescription)" ) self.aiDiagnosticRunning = false } @@ -319,8 +314,7 @@ public struct ModelProfileOption: Identifiable, Equatable { } catch { aiDiagnosticRunning = false aiDiagnosticStatus = text( - "Could not prepare redacted diagnostics: \(error.localizedDescription)", - "无法准备脱敏诊断数据:\(error.localizedDescription)" + "Could not prepare records for sending.\n\(error.localizedDescription)", "无法准备发送记录。\n\(error.localizedDescription)" ) } } @@ -344,12 +338,10 @@ public struct ModelProfileOption: Identifiable, Equatable { return } aiDiagnosticStatus = draft.isAbbreviated - ? text("GitHub draft opened with an abbreviated report. You can save and attach the full result file.", - "已打开 GitHub 草稿。内容较长,草稿包含摘要,可保存完整结果文件后添加为附件。") - : text("GitHub draft opened. Review the content there before submitting.", "已打开 GitHub 草稿,请在 GitHub 检查内容后提交。") + ? text("GitHub draft opened with a summary.\nSave the full result to add it as an attachment.", "已打开 GitHub 反馈草稿。\n内容较长,草稿仅包含摘要。\n可保存完整结果,作为附件添加。") + : text("GitHub draft opened.\nReview the content before submitting.", "已打开 GitHub 反馈草稿。\n请检查内容后再提交。") } catch { - aiDiagnosticStatus = text("Could not prepare the GitHub draft: \(error.localizedDescription)", - "无法准备 GitHub 草稿:\(error.localizedDescription)") + aiDiagnosticStatus = text("Could not prepare the feedback draft.\n\(error.localizedDescription)", "无法准备反馈草稿。\n\(error.localizedDescription)") } } public func scheduleAutoSave() { @@ -578,8 +570,8 @@ public struct ModelProfileOption: Identifiable, Equatable { availableModels = models modelListSucceeded = true modelListResult = models.isEmpty - ? text("No models found.", "未找到模型。") - : text("Loaded \(models.count) models.", "已加载 \(models.count) 个模型。") + ? text("No available models found.", "没有找到可用模型。") + : text("Found \(models.count) models.", "已获取 \(models.count) 个模型。") if settings.llm.model.isEmpty, models.count == 1 { settings.llm.model = models[0] } } catch is CancellationError { return @@ -665,8 +657,8 @@ public struct ModelProfileOption: Identifiable, Equatable { try action(program) cliEditorInstalled = try loadCLIEditorsAction?() ?? [:] notice = install - ? text("Installed; open a new terminal tab and restart the CLI.", "已安装;请打开新的终端标签页并重新启动 CLI。") - : text("Reset; new terminal tabs use the CLI's own editor settings.", "已恢复默认;新的终端标签页将使用 CLI 自己的编辑器设置。") + ? text("Installed.\nOpen a new terminal tab and restart the tool.", "安装完成。\n请新开终端标签页,重启对应工具。") + : text("Defaults restored.\nNew terminal tabs use the tool's own editor settings.", "已恢复默认。\n新终端标签页使用工具原有设置。") noticeIsError = false } catch { notice = error.localizedDescription; noticeIsError = true @@ -692,15 +684,15 @@ private struct ProviderDraft { public extension WorkingMode { func title(language: InterfaceLanguage) -> String { switch self { - case .silent: return language.text("Silent", "静默") - case .manual: return language.text("Manual", "手动") + case .silent: return language.text("Replace directly", "直接替换") + case .manual: return language.text("Click to rewrite", "点击改写") } } var symbol: String { switch self { case .silent: "moon"; case .manual: "cursorarrow" } } func detail(language: InterfaceLanguage) -> String { switch self { - case .silent: return language.text("A shortcut, then a quiet replacement.", "按下快捷键后直接安静地替换。") - case .manual: return language.text("Click the little bubble when you need it.", "需要时点击小气泡开始改写。") + case .silent: return language.text("Press a shortcut to rewrite and replace the original.", "按快捷键,改写后直接替换原文。") + case .manual: return language.text("Click the bubble to start a rewrite.", "点击气泡开始改写。") } } } diff --git a/Sources/SayoUI/ApplicationFilterSettingsView.swift b/Sources/SayoUI/ApplicationFilterSettingsView.swift index 8f3f0b7..1c629e1 100644 --- a/Sources/SayoUI/ApplicationFilterSettingsView.swift +++ b/Sources/SayoUI/ApplicationFilterSettingsView.swift @@ -42,32 +42,32 @@ struct ApplicationFilterSettingsView: View { VStack(alignment: .leading, spacing: 16) { // The settings page title already names this section. Text(mode == .blacklist - ? t("Sayo works everywhere except the apps you select.", "Sayo 会在除所选应用之外的所有应用中工作。") - : t("Sayo works only in the apps you select.", "Sayo 只会在你选择的应用中工作。")) + ? t("Use Sayo in every app except those selected.", "除所选应用外,其他应用都可使用。") + : t("Use Sayo only in the selected apps.", "只在所选应用中使用。")) .font(.system(size: 12)).foregroundStyle(SayoStyle.muted) HStack(spacing: 12) { - SayoSegmentedControl(title: t("App access mode", "应用范围模式"), + SayoSegmentedControl(title: t("Where to use Sayo", "使用方式"), options: [ApplicationFilterMode.blacklist, .whitelist], selection: $mode) { - $0 == .blacklist ? t("Blacklist", "黑名单") : t("Whitelist", "白名单") + $0 == .blacklist ? t("Except selected", "排除所选") : t("Only selected", "仅限所选") } .frame(width: 250) Spacer() - Text(t("Selected: \(selectedBundleIDs.count)", "已选择:\(selectedBundleIDs.count)")) + Text(t("Selected: \(selectedBundleIDs.count)", "已选:\(selectedBundleIDs.count)")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) - Button(t("Clear all", "全部清除"), role: .destructive) { selectedBundleIDs.removeAll() } + Button(t("Clear selection", "清空选择"), role: .destructive) { selectedBundleIDs.removeAll() } .disabled(selectedBundleIDs.isEmpty) } - Text(t("Click or drag apps between columns. 20 apps per page.", "点按或拖动应用可在两列之间移动,每页 20 个。")) + Text(t("Click or drag apps to move them between lists.\nEach page shows 20 apps.", "点击或拖动应用,即可调整。\n每页显示 20 个应用。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) HStack(alignment: .top, spacing: 12) { appColumn(title: t("Available apps", "可选应用"), apps: availableApps, page: $availablePage, selected: false, targeted: $availableTargeted) - appColumn(title: mode == .blacklist ? t("Blacklist", "黑名单") : t("Whitelist", "白名单"), + appColumn(title: mode == .blacklist ? t("Excluded apps", "排除应用") : t("Enabled apps", "启用应用"), apps: selectedApps, page: $selectedPage, selected: true, targeted: $selectedTargeted) } .animation(reduceMotion ? .easeOut(duration: 0.15) : .smooth(duration: 0.32), @@ -121,25 +121,25 @@ struct ApplicationFilterSettingsView: View { VStack(spacing: 0) { if visibleApps.isEmpty { Text(selected - ? t("Click or drag apps here to add them.", "点按左侧应用或拖到此处添加。") + ? t("Click an app on the left, or drag it here.", "点击左侧应用,或拖到这里。") : scanningInstalledApplications - ? t("Scanning applications…", "正在扫描应用…") - : t("No available apps.", "暂无可选应用。")) + ? t("Finding apps…", "正在查找应用…") + : t("No available apps.", "没有可选应用。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) .frame(maxWidth: .infinity, alignment: .leading).padding(12) .transition(.opacity) } if !visibleRunning.isEmpty || (currentPage == 0 && !apps.isEmpty) { - sectionHeader(t("Running now", "正在运行"), count: running.count) + sectionHeader(t("Open apps", "已打开"), count: running.count) if visibleRunning.isEmpty { - Text(t("No running apps in this list.", "此列表暂无正在运行的应用。")) + Text(t("No open apps in this list.", "列表中没有已打开的应用。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) .frame(maxWidth: .infinity, alignment: .leading).padding(8) } ForEach(visibleRunning) { app in appRow(app, selected: selected) } } if !visibleOther.isEmpty { - sectionHeader(t("All apps (excluding running)", "全部应用(不含正在运行)"), count: other.count) + sectionHeader(t("Other apps", "未打开"), count: other.count) ForEach(visibleOther) { app in appRow(app, selected: selected) } } }.padding(4) diff --git a/Sources/SayoUI/DiagnosticAnalysisView.swift b/Sources/SayoUI/DiagnosticAnalysisView.swift index f9da141..1d53db6 100644 --- a/Sources/SayoUI/DiagnosticAnalysisView.swift +++ b/Sources/SayoUI/DiagnosticAnalysisView.swift @@ -25,7 +25,7 @@ struct DiagnosticAnalysisView: View { var body: some View { VStack(alignment: .leading, spacing: 12) { aiDiagnosis - Picker(t("Category", "记录分类"), selection: $category) { + Picker(t("Record type", "记录类型"), selection: $category) { ForEach(DiagnosticCategory.allCases, id: \.self) { Text($0.title(language)).tag($0) } }.pickerStyle(.segmented) .onChange(of: category) { application = ""; outcome = ""; selectedID = nil } @@ -35,16 +35,16 @@ struct DiagnosticAnalysisView: View { ForEach(applications, id: \.key) { Text($0.name).tag($0.key) } }.frame(maxWidth: 230) if category == .invocation { - Picker(t("Outcome", "结果"), selection: $outcome) { + Picker(t("Outcome", "操作结果"), selection: $outcome) { Text(t("All outcomes", "全部结果")).tag("") - Text(t("Inserted", "发生追加")).tag("inserted_at_caret") + Text(t("Original kept", "保留原文")).tag("inserted_at_caret") Text(t("Failed", "操作失败")).tag("failed") Text(t("Replaced", "替换成功")).tag("replaced") }.frame(maxWidth: 210) } Spacer(minLength: 0) Button { model.refreshDiagnostics() } label: { Image(systemName: "arrow.clockwise") } - .help(t("Refresh", "刷新分析")) + .help(t("Refresh records", "刷新记录")) }.font(.system(size: 12)) Text(model.diagnosticStatus).font(.system(size: 10, design: .monospaced)).foregroundStyle(SayoStyle.muted) HStack(spacing: 0) { @@ -62,40 +62,40 @@ struct DiagnosticAnalysisView: View { } else { VStack(alignment: .leading, spacing: 9) { Image(systemName: "text.magnifyingglass").font(.title2) - Text(t("No matching records", "暂无匹配记录")).font(.headline) - Text(t("Invoke Sayo in the target app, then return here; earlier logs remain under Input observations and Unlinked history.", "在目标应用唤起 Sayo 后返回这里;旧日志仍可在「输入观察」和「历史未关联记录」查看。")) + Text(t("No matching records.", "没有符合条件的记录。")).font(.headline) + Text(t("Use Sayo once in the app you want to check.\nReturn here to view the record.\nEarlier records are under Input checks and Older records.", "在要检查的应用中使用一次。\n再回到这里查看记录。\n较早记录可在其他分类查看。")) .font(.system(size: 12)).foregroundStyle(SayoStyle.muted) }.padding(20).frame(maxWidth: .infinity, maxHeight: .infinity) } }.frame(height: 365).background(.white.opacity(0.65), in: RoundedRectangle(cornerRadius: 10)) .overlay(RoundedRectangle(cornerRadius: 10).stroke(SayoStyle.green.opacity(0.15))) if model.diagnosticAnalysis.unreadableLines > 0 { - Text(t("Skipped \(model.diagnosticAnalysis.unreadableLines) unreadable log lines.", "已跳过 \(model.diagnosticAnalysis.unreadableLines) 条无法解析的日志。")) + Text(t("Skipped \(model.diagnosticAnalysis.unreadableLines) unreadable records.", "已跳过 \(model.diagnosticAnalysis.unreadableLines) 条无法读取的记录。")) .font(.caption).foregroundStyle(.orange) } - DisclosureGroup(t("Recording and export", "记录选项与导出")) { + DisclosureGroup(t("Recording settings", "记录设置")) { VStack(alignment: .leading, spacing: 10) { - Text(t("Sayo analyzes all retained files, gives each invocation a restart-scoped ID, and keeps four rotating 512 KB files.", "Sayo 会分析全部保留日志,为每次唤起分配随重启重置的 ID,并轮转保留四个 512 KB 文件。")) - Toggle(t("Retain diagnostic logs", "保留诊断日志"), isOn: $model.settings.retainDiagnosticLogs) - Text(t("Disabling stops new records while keeping existing files available for export or removal.", "关闭后将停止新增记录,已有文件仍可导出或手动删除。")) + Text(t("All saved records are analyzed.\nEach attempt has a number that resets on restart.\nUp to four 512 KB files are kept.\nNew records replace the oldest when full.", "分析全部保留记录。\n每次操作有独立编号,重启后重置。\n最多保留四个 512 KB 文件。\n文件满后,替换最早的记录。")) + Toggle(t("Keep records", "保留记录"), isOn: $model.settings.retainDiagnosticLogs) + Text(t("Turning this off stops new records.\nExisting records can still be exported or removed manually.", "关闭后,不再添加记录。\n已有记录仍可导出或手动删除。")) .foregroundStyle(SayoStyle.muted) - Toggle(t("Include text snippets for this session (up to 120 characters)", "本次运行记录文本片段(最多 120 字符)"), isOn: Binding( + Toggle(t("Record text snippets", "记录文字"), isOn: Binding( get: { model.diagnosticTextSnippetsEnabled }, set: { model.diagnosticTextSnippetsEnabled = $0; model.diagnosticSnippetsAction?($0) } )).disabled(!model.settings.retainDiagnosticLogs) - Text(t("Text logging is off by default and resets on restart without removing existing snippets.", "正文记录默认关闭且重启后重置,但不会删除已有片段。")) + Text(t("Off by default. Records up to 120 characters.\nTurns off again when Sayo restarts.\nExisting text snippets are kept.", "默认关闭,最多记录 120 字符。\n重启后,自动关闭此选项。\n已有文字片段不会删除。")) .foregroundStyle(SayoStyle.muted) Text(model.diagnosticPath).font(.system(size: 10, design: .monospaced)).textSelection(.enabled) HStack { - Button(t("Open log folder", "打开日志文件夹")) { model.openDiagnostics() } - Button(t("Export all retained logs…", "导出全部保留日志…")) { model.exportDiagnosticsAction?() } + Button(t("Show files", "打开文件")) { model.openDiagnostics() } + Button(t("Export all…", "导出全部")) { model.exportDiagnosticsAction?() } } }.font(.system(size: 11)).padding(.top, 8) }.font(.system(size: 12)) } .sheet(isPresented: $showingAIDiagnosticResult) { VStack(alignment: .leading, spacing: 16) { - Text(t("Analysis result", "分析结果")).font(.title2.bold()) + Text(t("Troubleshooting result", "排查结果")).font(.title2.bold()) ScrollView { Text(model.aiDiagnosticResult) .font(.system(size: 13)) @@ -104,11 +104,10 @@ struct DiagnosticAnalysisView: View { .padding(12) } .background(SayoStyle.paper, in: RoundedRectangle(cornerRadius: 9)) - Text(t("The saved file includes the analysis and the redacted evidence sent to the model.", - "保存的文件包含分析结果,以及发送给模型的脱敏数据。")) + Text(t("The file contains the analysis and the records sent.\nSensitive details in those records are hidden.", "文件包含分析结果和发送的记录。\n发送记录中的敏感信息已隐藏。")) .font(.caption).foregroundStyle(SayoStyle.muted) HStack { - Button(t("Save result file…", "保存结果文件…")) { model.saveAIDiagnosticReport() } + Button(t("Save result…", "保存结果")) { model.saveAIDiagnosticReport() } Spacer() Button(t("Done", "完成")) { showingAIDiagnosticResult = false } .keyboardShortcut(.cancelAction) @@ -120,11 +119,10 @@ struct DiagnosticAnalysisView: View { SayoCard { HStack(alignment: .top, spacing: 18) { VStack(alignment: .leading, spacing: 7) { - Text(t("AI DIAGNOSIS · EXPERIMENTAL", "AI 自诊断 · 实验性功能")) + Text(t("Assisted troubleshooting", "智能排查")) .font(.system(size: 10, weight: .semibold)).tracking(1.3) Text(t( - "Scan failed cases from the past 30 minutes, then select which ones to analyze. Only after you authorize analysis will the redacted cases be sent to your configured language model. Input text, rewritten text, API keys, and prompts are excluded.", - "先检测过去 30 分钟内的失败案例,再勾选需要分析的案例。授权后才会将所选案例的脱敏数据发送给已配置的大模型,不包含输入原文、改写结果、API Key 和提示词。" + "This feature is experimental.\nFind failed attempts from the last 30 minutes.\nSelect records, then allow them to be sent for analysis.\nSelected records go to your current service.\nSensitive details are hidden before sending.\nOriginal text, rewrites, keys, and instructions are excluded.", "此功能仍在试用。\n先查找近 30 分钟的失败记录。\n勾选记录后,可授权发送分析。\n所选记录会发送给当前服务。\n发送前会隐藏敏感信息。\n不发送原文、结果、密钥和改写要求。" )) .font(.system(size: 12)).foregroundStyle(SayoStyle.muted) .fixedSize(horizontal: false, vertical: true) @@ -134,7 +132,7 @@ struct DiagnosticAnalysisView: View { model.prepareAIDiagnostics() } label: { Text(model.aiDiagnosticCandidates == nil - ? t("Scan failed cases", "检测错误案例") : t("Scan again", "重新检测")) + ? t("Find failed attempts", "查找失败") : t("Search again", "重新查找")) } .disabled(model.aiDiagnosticRunning) .accessibilityIdentifier("start-ai-diagnosis") @@ -150,14 +148,13 @@ struct DiagnosticAnalysisView: View { if !model.aiDiagnosticResult.isEmpty { Divider() HStack { - Button(t("View analysis result", "查看分析结果")) { showingAIDiagnosticResult = true } + Button(t("View result", "查看结果")) { showingAIDiagnosticResult = true } .accessibilityIdentifier("view-ai-diagnosis") - Button(t("Report an issue to the author", "给作者提 issue")) { model.openAIDiagnosticIssue() } + Button(t("Report a problem", "反馈问题")) { model.openAIDiagnosticIssue() } .accessibilityIdentifier("report-ai-diagnosis-issue") Spacer() } - Text(t("Opens a GitHub draft containing the redacted analysis and selected cases. Review it on GitHub before submitting.", - "将在 GitHub 打开含脱敏分析结果与所选案例的 issue 草稿,由你检查后提交。")) + Text(t("Open a feedback draft on GitHub.\nIt includes the analysis and selected records.\nSensitive details are hidden. Review it before submitting.", "在 GitHub 打开反馈草稿。\n包含分析结果和所选记录。\n敏感信息已隐藏,请检查后提交。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) } } @@ -165,8 +162,7 @@ struct DiagnosticAnalysisView: View { private func aiDiagnosticSelection(_ candidates: AIDiagnosticEvidence) -> some View { VStack(alignment: .leading, spacing: 10) { HStack { - Text(t("Selected \(model.aiDiagnosticSelectedCases.count) of \(candidates.failures.count)", - "已选 \(model.aiDiagnosticSelectedCases.count) / \(candidates.failures.count) 个案例")) + Text(t("Selected \(model.aiDiagnosticSelectedCases.count) of \(candidates.failures.count)", "已选 \(model.aiDiagnosticSelectedCases.count) / \(candidates.failures.count) 条")) Spacer() Button(t("Select all", "全选")) { model.selectAllAIDiagnosticCases() } Button(t("Invert selection", "反选")) { model.invertAIDiagnosticSelection() } @@ -201,7 +197,7 @@ struct DiagnosticAnalysisView: View { if model.aiDiagnosticRunning { ProgressView().controlSize(.small) } Button(model.aiDiagnosticRunning ? t("Analyzing…", "分析中…") - : t("Next: authorize analysis with the configured model", "下一步:授权使用已配置的大模型进行分析")) { + : t("Allow analysis", "授权分析")) { model.runAIDiagnostics() } .disabled(model.aiDiagnosticSelectedCases.isEmpty || model.aiDiagnosticRunning) @@ -240,13 +236,13 @@ struct DiagnosticAnalysisView: View { Text(failure.explanation(language)).font(.system(size: 12)).foregroundStyle(.red) } if group.incomplete || group.category == .history { - Text(t("This incomplete or older record cannot be reconstructed into a full sequence.", "这条不完整或较旧的记录无法还原完整过程。")) + Text(t("This older or incomplete record cannot show every step.", "记录较旧或不完整,无法还原过程。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) } HStack { - Text(group.category == .invocation ? t("Timeline", "过程时间线") : t("Events · newest first", "事件 · 最新在上")).font(.system(size: 12, weight: .semibold)) + Text(group.category == .invocation ? t("Steps", "操作过程") : t("Newest first", "最新在上")).font(.system(size: 12, weight: .semibold)) Spacer() - Button(t("Export this record…", "导出本次记录…")) { model.exportDiagnosticGroupAction?(group) } + Button(t("Export this record…", "导出本次")) { model.exportDiagnosticGroupAction?(group) } .font(.system(size: 10)) } LazyVStack(alignment: .leading, spacing: 13) { @@ -255,7 +251,7 @@ struct DiagnosticAnalysisView: View { Text("\(index + 1) · " + time(event.date, date: false) + (event.fields["elapsedMs"].map { " · +\($0) ms" } ?? "")) .font(.system(size: 10, design: .monospaced)).foregroundStyle(SayoStyle.muted) Text(event.explanation(language)).font(.system(size: 12)).fixedSize(horizontal: false, vertical: true) - DisclosureGroup(t("Raw fields", "原始字段")) { + DisclosureGroup(t("Details", "详细信息")) { Text(event.rawText).font(.system(size: 10, design: .monospaced)) .textSelection(.enabled).fixedSize(horizontal: false, vertical: true) }.font(.system(size: 10)).foregroundStyle(SayoStyle.muted) diff --git a/Sources/SayoUI/ModelConnectionTestView.swift b/Sources/SayoUI/ModelConnectionTestView.swift index 69bda8f..d878cb6 100644 --- a/Sources/SayoUI/ModelConnectionTestView.swift +++ b/Sources/SayoUI/ModelConnectionTestView.swift @@ -10,7 +10,7 @@ struct ModelConnectionTestView: View { HStack(spacing: 12) { VStack(alignment: .leading, spacing: 5) { Text(t("Connection test", "连接测试")).font(.system(size: 13, weight: .semibold)) - Text(t("Check the response and measure total latency.", "检查模型响应,并测量完整请求耗时。")) + Text(t("Check that it works and see how long a response takes.", "检查能否使用,以及等待多久。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) } Spacer(minLength: 8) @@ -23,19 +23,19 @@ struct ModelConnectionTestView: View { } if model.settings.llm.provider == .chromeNano { HStack(spacing: 8) { - Text(t("Current connection status:", "当前连接状态:")) + Text(t("Connection status", "连接状态")) Text(model.nanoConnected ? t("Connected", "已连接") : t("Not connected", "未连接")) .foregroundStyle(model.nanoConnected ? SayoStyle.green : SayoStyle.muted) .accessibilityIdentifier("nano-connection-status") Button { model.refreshNanoConnection() } label: { Image(systemName: "arrow.clockwise") } - .help(t("Refresh connection status", "刷新连接状态")) - .accessibilityLabel(t("Refresh connection status", "刷新连接状态")) + .help(t("Refresh status", "刷新状态")) + .accessibilityLabel(t("Refresh status", "刷新状态")) .accessibilityIdentifier("refresh-nano-connection") } .font(.system(size: 12)) - Button(t("Connect Chrome…", "连接 Chrome…")) { model.connectNano() } + Button(t("Open connection…", "打开连接")) { model.connectNano() } .disabled(model.connectingNano || model.testingConnection) .accessibilityIdentifier("connect-chrome-nano") } @@ -47,7 +47,7 @@ struct ModelConnectionTestView: View { Image(systemName: model.connectionSucceeded ? "checkmark.circle.fill" : "exclamationmark.circle.fill") .foregroundStyle(model.connectionSucceeded ? SayoStyle.green : Color.orange) } - Text(model.testingConnection ? t("Waiting for the model…", "正在等待模型响应…") : model.connectionResult) + Text(model.testingConnection ? t("Waiting for a result…", "正在等待结果…") : model.connectionResult) .font(.system(size: 12)).textSelection(.enabled) .fixedSize(horizontal: false, vertical: true) .accessibilityIdentifier("connection-test-result") @@ -65,10 +65,10 @@ struct ModelConnectionTestView: View { } if !model.connectionOriginal.isEmpty { VStack(alignment: .leading, spacing: 14) { - sentence(t("Original", "原语句"), model.connectionOriginal, id: "connection-original") + sentence(t("Original", "原文"), model.connectionOriginal, id: "connection-original") Divider() - sentence(t("Processed", "处理后"), model.testingConnection ? t("Processing…", "处理中…") : - model.connectionSucceeded ? model.connectionOutput : t("No result (test failed)", "未生成(测试失败)"), + sentence(t("Rewritten text", "改写结果"), model.testingConnection ? t("Processing…", "处理中…") : + model.connectionSucceeded ? model.connectionOutput : t("The test failed. No result was generated.", "测试失败,未生成结果。"), id: "connection-output") } .padding(14).background(SayoStyle.field.opacity(0.7), in: RoundedRectangle(cornerRadius: 9)) @@ -91,9 +91,9 @@ struct ModelConnectionTestView: View { } private func elapsedDescription(_ milliseconds: UInt64) -> String { - if milliseconds < 1_000 { return t("Elapsed: \(milliseconds) ms", "耗时:\(milliseconds) 毫秒") } + if milliseconds < 1_000 { return t("Time: \(milliseconds) ms", "用时:\(milliseconds) 毫秒") } let seconds = String(format: "%.2f", Double(milliseconds) / 1_000) - return t("Elapsed: \(seconds) s", "耗时:\(seconds) 秒") + return t("Time: \(seconds) s", "用时:\(seconds) 秒") } private func sentence(_ title: String, _ content: String, id: String) -> some View { diff --git a/Sources/SayoUI/ModelProfileEditorView.swift b/Sources/SayoUI/ModelProfileEditorView.swift index 4aab80e..48a628f 100644 --- a/Sources/SayoUI/ModelProfileEditorView.swift +++ b/Sources/SayoUI/ModelProfileEditorView.swift @@ -44,8 +44,7 @@ import SayoCore } guard configuration.provider == .chromeNano || !configuration.baseURL.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty, !configuration.model.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else { - errorMessage = parent.text("Enter a Base URL and model name before saving.", - "保存前请填写 Base URL 和模型名称。") + errorMessage = parent.text("Enter the service address and model name before saving.", "请先填写服务地址和模型名称。") return false } guard parent.commitModelProfile(profileID, configuration: configuration, apiKey: draft.apiKey) else { @@ -81,7 +80,7 @@ public struct ModelProfileEditorView: View { HStack(spacing: 14) { ProviderBadge(provider: draft.settings.llm.provider, size: 44) VStack(alignment: .leading, spacing: 4) { - Text(session.isNew ? t("Add model", "新增模型") : t("Edit model", "编辑模型")) + Text(session.isNew ? t("Add service", "添加服务") : t("Edit service", "编辑服务")) .font(.system(size: 23, weight: .semibold)) Text(providerName) .font(.system(size: 12)).foregroundStyle(SayoStyle.muted) @@ -89,7 +88,7 @@ public struct ModelProfileEditorView: View { Spacer() if let website = draft.settings.llm.provider.homepageURL { Link(destination: website) { - Label(t("Website", "官网"), systemImage: "arrow.up.right") + Label(t("Official website", "官方网站"), systemImage: "arrow.up.right") .font(.system(size: 12)) } } @@ -100,9 +99,9 @@ public struct ModelProfileEditorView: View { if draft.settings.llm.provider == .chromeNano { nanoIntroduction } else { - field(t("API format", "API 格式")) { + field(t("Connection type", "连接类型")) { VStack(alignment: .leading, spacing: 9) { - SayoSegmentedControl(title: t("API format", "API 格式"), + SayoSegmentedControl(title: t("Connection type", "连接类型"), options: ModelAPIFormat.allCases, selection: Binding( get: { draft.settings.llm.resolvedAPIFormat }, set: { draft.settings.llm.apiFormat = $0 } @@ -112,23 +111,23 @@ public struct ModelProfileEditorView: View { .fixedSize(horizontal: false, vertical: true) } } - field("Base URL") { + field(t("Service address", "服务地址")) { TextField(draft.settings.llm.provider == .custom ? "https://api.example.com/v1" : draft.settings.llm.provider.defaultBaseURL, text: $draft.settings.llm.baseURL) .accessibilityIdentifier("editor-base-url") } - field("API Key") { + field(t("Service key", "服务密钥")) { VStack(alignment: .leading, spacing: 7) { SecureField("sk-…", text: $draft.apiKey) .accessibilityIdentifier("editor-api-key") - Text(t("Saved securely in this Mac's Keychain.", "密钥安全保存在本机的 macOS 钥匙串中。")) + Text(t("Your key is saved in this Mac's Keychain.", "密钥保存在本机系统钥匙串。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) } } - field(t("Model", "模型")) { + field(t("Model name", "模型名称")) { VStack(alignment: .leading, spacing: 9) { - TextField(t("Enter a model name", "输入模型名称"), text: $draft.settings.llm.model) + TextField(t("Enter the model name", "填写模型名称"), text: $draft.settings.llm.model) .accessibilityIdentifier("editor-model-name") HStack(spacing: 8) { if !draft.availableModels.isEmpty { @@ -175,11 +174,11 @@ public struct ModelProfileEditorView: View { } Divider() HStack(spacing: 10) { - Text(t("Use this model after saving.", "保存后使用此模型。")) + Text(t("Use this service as soon as you save it.", "保存后,立即使用此服务。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) Spacer() Button(t("Cancel", "取消"), action: onCancel).keyboardShortcut(.cancelAction) - Button(t("Save model", "保存模型")) { + Button(t("Save service", "保存服务")) { if session.save() { onSaved() } } .buttonStyle(SayoButtonStyle(prominent: true)) @@ -205,10 +204,10 @@ public struct ModelProfileEditorView: View { private var formatDescription: String { switch draft.settings.llm.resolvedAPIFormat { - case .chatCompletions: return t("Chat Completions · Supported by most compatible services.", "Chat Completions · 适用于大多数兼容 OpenAI 的服务。") - case .responses: return t("Responses · For services using the OpenAI Responses API.", "适用于提供 OpenAI Responses 接口的服务。") - case .anthropic: return t("Messages · For Claude and Anthropic-compatible services.", "Messages · 适用于 Claude 及兼容 Anthropic 的服务。") - case .gemini: return t("GenerateContent · For Google Gemini-compatible services.", "GenerateContent · 适用于兼容 Google Gemini 的服务。") + case .chatCompletions: return t("Chat Completions\nFor most services compatible with OpenAI.", "Chat Completions\n适用于多数兼容 OpenAI 的服务。") + case .responses: return t("For services that provide OpenAI Responses.", "适用于提供 Responses 的服务。") + case .anthropic: return t("Messages\nFor Claude and services compatible with Anthropic.", "Messages\n适用于 Claude 及兼容服务。") + case .gemini: return t("GenerateContent\nFor services compatible with Google Gemini.", "GenerateContent\n适用于兼容 Gemini 的服务。") } } private var providerName: String { @@ -222,31 +221,24 @@ public struct ModelProfileEditorView: View { private var nanoIntroduction: some View { VStack(alignment: .leading, spacing: 10) { - Label(t("On-device AI · No API key", "本地 AI · 无需 API Key"), systemImage: "desktopcomputer") + Label(t("On this Mac", "本机处理"), systemImage: "desktopcomputer") .font(.system(size: 14, weight: .medium)) - Text(t("Gemini Nano is Google's small AI model, downloaded and managed by Chrome for its built-in AI features.", - "Gemini Nano 是 Google 的轻量 AI 模型,由 Chrome 下载和管理,供浏览器内置 AI 功能使用。")) - Text(t("Sayo processes your text on this Mac through Chrome. Connecting opens an extra local Chrome page; keep it open while using the model.", - "Sayo 通过 Chrome 在本机处理文本。连接时会额外打开一个 Chrome 本机页面,使用期间需保持开启。")) - Text(t("Official input and output languages: English, Japanese, Spanish, German and French. Sayo also allows Chinese and other languages as experimental use; translations may be incomplete or inaccurate.", - "官方支持的输入和输出语言:英语、日语、西班牙语、德语、法语。中文等其他语言可作为实验性功能使用,Sayo 不作语言限制,但翻译可能不完整或不准确。")) + Text(t("Provided by Google. Downloaded and managed by Chrome.", "由谷歌提供,浏览器下载和管理。")) + Text(t("Chrome processes your text on this Mac.\nConnecting opens a local page.\nKeep it open while you use this service.", "文字由本机浏览器处理。\n连接时会打开一个页面。\n使用期间,请保持页面开启。")) + Text(t("Supported languages: English, Japanese, and Spanish.\nGerman and French are also supported.\nChinese and other languages are experimental.\nResults may be incomplete or inaccurate.", "正式支持英语、日语、西班牙语。\n也支持德语和法语。\n中文等其他语言仍在试用。\n结果可能不完整或不准确。")) .foregroundStyle(SayoStyle.ink) .accessibilityIdentifier("nano-language-limits") - DisclosureGroup(t("More about the model and connection", "模型来源、连接方式与限制"), + DisclosureGroup(t("How to use it", "使用说明"), isExpanded: $showingNanoDetails) { VStack(alignment: .leading, spacing: 12) { - nanoDetail(t("Why is it on my Mac?", "为什么电脑上会有?"), - t("Chrome's AI features may have already downloaded it as “Optimization Guide On Device Model”. Sayo reuses the model through Chrome; not every Mac has it installed.", - "Chrome 的 AI 功能可能已下载它,对应组件名为「Optimization Guide On Device Model」。Sayo 会通过 Chrome 复用它,并非每台电脑都已安装。")) - nanoDetail(t("What stays local?", "是否完全本地处理?"), - t("This connection sends text only to Chrome on this Mac and returns the result to Sayo. It does not call a cloud model. Chrome still needs internet access to download or update the model.", - "此连接只把文本交给本机 Chrome 推理,再将结果传回 Sayo,不调用云端模型。模型下载和更新仍需由 Chrome 联网完成。")) - nanoDetail(t("Do I need to build a website?", "需要自己搭建网页吗?"), - t("No. Sayo temporarily provides the local connection page; nothing needs to be hosted or published. Click Connect model on that page, then return here to test. Reconnect if the tab or Chrome closes, or Sayo restarts.", - "不需要。连接页由 Sayo 临时在本机提供,无需搭建或发布网站。在页面点击「连接模型」,再回到这里测试。关闭标签页、退出 Chrome 或重启 Sayo 后需重新连接。")) - nanoDetail(t("Other limits", "还有哪些限制?"), - t("Requires Chrome 148 or later and compatible hardware, free space and browser policies. The first connection may download several GB. Speed and text length are limited by the device and model. Test the connection to check availability.", - "需要 Chrome 148 或更高版本,并满足硬件、可用空间和浏览器策略要求。首次连接可能下载数 GB;处理速度和文本长度受设备及模型限制。请通过测试连接检查可用性。")) + nanoDetail(t("Where it comes from", "下载来源"), + t("Chrome may have already downloaded it.\nSome Macs need to download it first.\nThe component is named:\nOptimization Guide On Device Model", "浏览器可能已经下载了它。\n部分电脑需要先下载。\n下载组件名称:\nOptimization Guide On Device Model")) + nanoDetail(t("Where your text goes", "文字去向"), + t("Your text is processed only on this Mac.\nDownloads and updates still need an internet connection.", "文字只在本机处理。\n下载和更新仍需联网。")) + nanoDetail(t("Connection steps", "连接步骤"), + t("You do not need to build a website.\nClick Connect model on the page that opens.\nReturn here and click Test connection.\nReconnect if the page, Chrome, or Sayo closes.", "无需自己搭建网页。\n在打开的页面点击“连接模型”。\n返回此处,点击“测试连接”。\n页面或应用关闭后,需重新连接。")) + nanoDetail(t("Requirements", "使用条件"), + t("Requires Chrome 148 or later.\nYour hardware, free space, and browser settings must support it.\nThe first download may be several GB.\nSpeed and text length depend on the device and model.\nTest the connection to check availability.", "需要 Chrome 148 或更高版本。\n设备、空间和浏览器设置需符合要求。\n首次下载可能占用数 GB。\n速度和文字长度受设备限制。\n请先测试是否可用。")) } .padding(.top, 8) } diff --git a/Sources/SayoUI/OnboardingView.swift b/Sources/SayoUI/OnboardingView.swift index 2fb007b..d023bdc 100644 --- a/Sources/SayoUI/OnboardingView.swift +++ b/Sources/SayoUI/OnboardingView.swift @@ -116,8 +116,8 @@ public struct OnboardingView: View { } HStack(alignment: .top, spacing: 10) { Image(systemName: "lightbulb").foregroundStyle(SayoStyle.accent) - Text(t("Choose a target language and type naturally in an input field. Trigger a rewrite with your selected mode; when a result bubble appears, copy or replace it. Silent mode replaces directly. If you have not connected a model, visit Settings → Language Model later.", - "选择目标语言,在输入框中自然输入,再按所选模式触发改写。出现结果气泡时可复制或替换;静默模式会直接替换。如尚未连接模型,可稍后前往“设置 → 语言模型”配置。")) + Text(t("Choose a language and type in an input field.\nStart a rewrite using your selected mode.\nCopy or replace the result in the bubble.\nReplace directly uses a shortcut to replace the original.\nYou can add a service later in Settings → Text services.", + "选择语言,在输入框中输入文字。\n按所选方式开始改写。\n气泡中的结果可复制或替换。\n“直接替换”按快捷键后替换原文。\n稍后可在设置中添加服务。\n位置:“翻译服务”。")) .font(.system(size: 12)).foregroundStyle(SayoStyle.muted).fixedSize(horizontal: false, vertical: true) }.padding(14).frame(maxWidth: .infinity, alignment: .leading) .background(SayoStyle.accent.opacity(0.06), in: RoundedRectangle(cornerRadius: 10)) diff --git a/Sources/SayoUI/SayoDesignSystem.swift b/Sources/SayoUI/SayoDesignSystem.swift index 18a7e9f..a655333 100644 --- a/Sources/SayoUI/SayoDesignSystem.swift +++ b/Sources/SayoUI/SayoDesignSystem.swift @@ -191,7 +191,7 @@ struct SayoCopyValue: View { } .buttonStyle(.plain) .help(language.text("Copy", "复制")) - .accessibilityLabel(language.text("Copy Base URL", "复制 Base URL")) + .accessibilityLabel(language.text("Copy service address", "复制地址")) .task(id: copied) { guard copied else { return } do { try await Task.sleep(for: .seconds(2)); copied = false } catch {} @@ -218,11 +218,11 @@ struct ModelProfilePickerView: View { } var body: some View { VStack(alignment: .leading, spacing: 12) { - Text(adding ? language.text("Add provider", "新增供应商") : language.text("Switch provider", "切换供应商")) + Text(adding ? language.text("Add service", "添加服务") : language.text("Switch service", "切换服务")) .font(.system(size: 15, weight: .semibold)) HStack(spacing: 8) { Image(systemName: "magnifyingglass").foregroundStyle(SayoStyle.muted) - TextField(language.text("Search providers or models", "搜索供应商或模型"), text: $query) + TextField(language.text("Search services or models", "搜索服务或模型"), text: $query) .textFieldStyle(.plain).font(.system(size: 12)) .focused($searchFocused) .accessibilityIdentifier("model-profile-search") @@ -254,7 +254,7 @@ struct ModelProfilePickerView: View { .buttonStyle(.plain) } if filteredProfiles.isEmpty { - Text(language.text("No matching providers", "没有匹配的供应商")) + Text(language.text("No matching services.", "没有找到相关服务。")) .font(.system(size: 12)).foregroundStyle(SayoStyle.muted) .padding(.vertical, 24) } @@ -311,7 +311,7 @@ struct ModelNamePickerView: View { } if filtered.isEmpty { Text(status.isEmpty - ? language.text("No matching models", "没有匹配的模型") + ? language.text("No matching models.", "没有找到相关模型。") : status) .font(.system(size: 12)).foregroundStyle(SayoStyle.muted).padding(10) } @@ -320,7 +320,7 @@ struct ModelNamePickerView: View { if loading { HStack(spacing: 8) { ProgressView().controlSize(.small) - Text(language.text("Loading models…", "正在加载模型…")) + Text(language.text("Getting the model list…", "正在获取模型列表…")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) } } else if !status.isEmpty, !filtered.isEmpty { diff --git a/Sources/SayoUI/SettingsView.swift b/Sources/SayoUI/SettingsView.swift index b042d23..cbe72ab 100644 --- a/Sources/SayoUI/SettingsView.swift +++ b/Sources/SayoUI/SettingsView.swift @@ -75,7 +75,7 @@ public struct SettingsView: View { case .saved: Image(systemName: "checkmark") .font(.system(size: 10, weight: .semibold)) - Text(t("Saved", "保存完毕")) + Text(t("Saved", "已保存")) case .failed: Image(systemName: "exclamationmark.circle") .font(.system(size: 11, weight: .medium)) @@ -96,11 +96,11 @@ public struct SettingsView: View { } } .padding(.horizontal, 21).padding(.top, 24).padding(.bottom, 30) - sidebarLabel(t("WORKSPACE", "工作区")) + sidebarLabel(t("Everyday", "常用设置")) ForEach(SettingsPage.standardPages(for: model.features).filter { [.general, .model, .rewriting].contains($0) }) { item in sidebarButton(item) } - sidebarLabel(t("TOOLS", "工具")).padding(.top, 20) + sidebarLabel(t("Tools", "使用设置")).padding(.top, 20) ForEach(SettingsPage.standardPages(for: model.features).filter { [.shortcuts, .appAccess, .terminal].contains($0) }) { item in sidebarButton(item) } @@ -118,7 +118,7 @@ public struct SettingsView: View { } else { Button { model.permissionAction?() } label: { accessibilityStatus } .buttonStyle(.plain) - .help(t("Enable Accessibility…", "启用辅助功能…")) + .help(t("Enable access…", "开启权限")) } }.font(.system(size: 10, weight: .medium)).padding(20) }.frame(width: 190).background(SayoStyle.field.opacity(0.65)) @@ -131,7 +131,7 @@ public struct SettingsView: View { private var accessibilityStatus: some View { HStack(spacing: 7) { Circle().fill(model.accessibilityGranted ? SayoStyle.green : Color.orange).frame(width: 6, height: 6) - Text(model.accessibilityGranted ? t("Accessibility enabled", "辅助功能已启用") : t("Accessibility disabled", "辅助功能未启用")) + Text(model.accessibilityGranted ? t("Access enabled", "权限已开") : t("Access needed", "权限未开")) }.contentShape(Rectangle()) } private func sidebarButton(_ item: SettingsPage) -> some View { @@ -157,16 +157,16 @@ public struct SettingsView: View { Group { if model.supportsFocusedInput && !model.accessibilityGranted { SayoCard { - SayoSettingRow(title: t("Let Sayo work where you type", "让 Sayo 在你输入的地方工作"), - detail: t("Accessibility lets Sayo read and replace the active input.", "开启辅助功能权限,即可读取并替换当前输入框内容。")) { - Button(t("Enable…", "启用…")) { model.permissionAction?() } + SayoSettingRow(title: t("Text access", "输入权限"), + detail: t("Allow Sayo to read and replace text where you type.", "开启后,可读取并替换输入内容。")) { + Button(t("Enable access…", "开启权限")) { model.permissionAction?() } .buttonStyle(SayoButtonStyle(prominent: true)) } } } SayoCard { sectionLabel(t("Languages", "语言")) - SayoSettingRow(title: t("Interface language", "界面语言"), detail: t("The language Sayo speaks to you.", "Sayo 界面的显示语言。")) { + SayoSettingRow(title: t("Interface language", "界面语言"), detail: t("The language used for menus and buttons.", "菜单和按钮使用的语言。")) { Picker("", selection: $model.settings.interfaceLanguage) { ForEach(InterfaceLanguage.allCases, id: \.self) { language in Text(language.displayName).tag(language) @@ -175,66 +175,65 @@ public struct SettingsView: View { .accessibilityLabel(t("Interface language", "界面语言")) } Divider() - SayoSettingRow(title: t("First language", "第一语言"), detail: t("Your default translation destination.", "日常翻译与改写使用的目标语言。")) { + SayoSettingRow(title: t("Main language", "常用语言"), detail: t("Your usual language for translations and rewrites.", "平时翻译和改写成这种语言。")) { Picker("", selection: $model.settings.targetLanguage) { ForEach(TargetLanguage.allCases, id: \.self) { language in Text(model.targetLanguageName(language)).tag(language) } }.labelsHidden().frame(width: 180) - .accessibilityLabel(t("First language", "第一语言")) + .accessibilityLabel(t("Main language", "常用语言")) } if model.supportsFocusedInput { Divider() - SayoSettingRow(title: t("Second language", "第二语言"), detail: t("Use a separate shortcut to translate into this language.", "通过独立快捷键,快速翻译为另一种语言。")) { + SayoSettingRow(title: t("Other language", "另一语言"), detail: t("Use a separate shortcut to translate into this language.", "按专用快捷键,翻译成这种语言。")) { Picker("", selection: $model.settings.secondaryTargetLanguage) { ForEach(TargetLanguage.allCases, id: \.self) { language in Text(model.targetLanguageName(language)).tag(language) } }.labelsHidden().frame(width: 180) - .accessibilityLabel(t("Second language", "第二语言")) + .accessibilityLabel(t("Other language", "另一语言")) } HStack(spacing: 6) { let shortcut = model.settings.secondaryShortcut?.displayLabel(language: model.settings.interfaceLanguage) ?? t("Not set", "未设置") Image(systemName: "keyboard") - Text(t("Second-language shortcut: \(shortcut)", "第二语言快捷键:\(shortcut)")) + Text(t("Other-language shortcut: \(shortcut)", "专用快捷键:\(shortcut)")) Spacer() - pageLink(t("Set shortcut", "设置快捷键"), to: .shortcuts) + pageLink(t("Set shortcut", "设置按键"), to: .shortcuts) } .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) .padding(11).background(SayoStyle.field, in: RoundedRectangle(cornerRadius: 8)) } } SayoCard { - sectionLabel(t("App behavior", "应用行为")) - toggleRow(t("Open Sayo at login", "登录时启动 Sayo"), isOn: $model.settings.launchAtLogin, - detail: t("Ready whenever you start writing.", "每次打开电脑,即可开始使用。")) + sectionLabel(t("Startup and appearance", "启动外观")) + toggleRow(t("Open at login", "登录启动"), isOn: $model.settings.launchAtLogin, + detail: t("Start Sayo when you log in to your Mac.", "登录电脑后,自动启动。")) Divider() - SayoSettingRow(title: t("Status bar icon", "状态栏图标"), - detail: t("Monochrome adapts to your menu bar appearance.", "单色图标会自动适应菜单栏的深浅外观。")) { + SayoSettingRow(title: t("Menu bar icon", "菜单图标"), + detail: t("The monochrome icon follows your menu bar's appearance.", "单色图标随菜单栏深浅变化。")) { Picker("", selection: $model.settings.statusBarIconStyle) { Text(t("Chameleon", "变色龙")).tag(StatusBarIconStyle.brand) - Text(t("Monochrome", "单色(macOS)")).tag(StatusBarIconStyle.monochrome) + Text(t("Monochrome", "单色")).tag(StatusBarIconStyle.monochrome) }.labelsHidden().frame(width: 145) - .accessibilityLabel(t("Status bar icon", "状态栏图标")) + .accessibilityLabel(t("Menu bar icon", "菜单图标")) StatusIconPreview(style: $model.settings.statusBarIconStyle).frame(width: 44, height: 44) } } SayoCard { - DisclosureGroup(t("Advanced settings", "高级设置")) { + DisclosureGroup(t("More settings", "更多设置")) { VStack(alignment: .leading, spacing: 16) { - SayoSettingRow(title: t("Settings file", "配置文件")) { - Button(t("Show in Finder", "在 Finder 中显示")) { model.openConfigAction?() } + SayoSettingRow(title: t("Settings file", "设置文件")) { + Button(t("Show in Finder", "打开位置")) { model.openConfigAction?() } } Text(model.configPath).font(.system(size: 11, design: .monospaced)).textSelection(.enabled) .foregroundStyle(SayoStyle.muted) - Text(t("API keys stay in macOS Keychain. To migrate, quit Sayo, copy this file to the same location, reopen Sayo, and re-enter API keys on a new Mac.", - "API Key 单独保存在 macOS 钥匙串中。迁移时先退出 Sayo,将此文件复制到相同位置后重新启动,并在新 Mac 上重新填写 API Key。")) + Text(t("Keys are stored separately in Keychain.\nTo move your settings, quit Sayo first.\nCopy this file to the same location on your new Mac.\nReopen Sayo and enter your keys again.", "密钥单独保存在系统钥匙串。\n换电脑前,请先退出应用。\n将设置文件复制到相同位置。\n重新启动后,再填写密钥。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) Divider() - toggleRow(t("Developer mode", "开发者模式"), isOn: $model.settings.developerMode, - detail: t("Show Quick Troubleshooting in the sidebar.", "在侧栏显示快速排查。")) + toggleRow(t("Troubleshooting tools", "排查工具"), isOn: $model.settings.developerMode, + detail: t("Show Troubleshooting in the sidebar.", "在侧栏显示“问题排查”。")) Divider() - Button(t("Replay welcome tour", "重新查看欢迎引导")) { model.showOnboardingAction?() } + Button(t("Getting started", "使用入门")) { model.showOnboardingAction?() } }.padding(.top, 16) } .font(.system(size: 13, weight: .medium)) @@ -245,7 +244,7 @@ public struct SettingsView: View { Group { if model.supportsFocusedInput { SayoCard { - sectionLabel(t("WORKING MODE", "工作模式")) + sectionLabel(t("How to rewrite", "操作方式")) HStack(spacing: 10) { ForEach(WorkingMode.allCases, id: \.self) { mode in Button { model.changeWorkingMode(mode) } label: { @@ -268,32 +267,31 @@ public struct SettingsView: View { } } SayoCard { - sectionLabel(t("PROMPT", "提示词")) + sectionLabel(t("Rewrite instructions", "改写要求")) if model.supportsFocusedInput { - SayoSegmentedControl(title: t("Translation prompt", "翻译提示词"), + SayoSegmentedControl(title: t("Rewrite instructions", "改写要求"), options: [TranslationDestination.primary, .secondary], selection: $promptDestination) { - $0 == .primary ? t("First language", "第一语言") : t("Second language", "第二语言") + $0 == .primary ? t("Main language", "常用语言") : t("Other language", "另一语言") }.frame(width: 240) } HStack(spacing: 6) { let language = model.targetLanguageName(selectedPromptLanguage) - Text(t("Target: \(language). ${targetLanguage} in the prompt is replaced with it.", - "目标语言:\(language)。提示词中的 ${targetLanguage} 会替换为该语言。")) - pageLink(t("Change in General", "在“通用”中更改"), to: .general) + Text(t("Rewrite in: \(language).\nThe language marker becomes your selected language.\nLanguage marker: ${targetLanguage}", "改写成:\(language)。\n语言标记会自动换成所选语言。\n语言标记:${targetLanguage}")) + pageLink(t("Change language", "更改语言"), to: .general) }.font(.system(size: 11)).foregroundStyle(SayoStyle.muted) TextEditor(text: selectedPrompt).font(.system(size: 13, design: .monospaced)) .lineSpacing(5).scrollContentBackground(.hidden).padding(12).frame(height: 270) .background(SayoStyle.paper, in: RoundedRectangle(cornerRadius: 10)) - .accessibilityLabel(promptDestination == .primary ? t("First-language prompt", "第一语言提示词") : t("Second-language prompt", "第二语言提示词")) + .accessibilityLabel(promptDestination == .primary ? t("Main-language instructions", "常用要求") : t("Other-language instructions", "另一要求")) HStack { - Text(t("Keep “return only the final text” for clean replacements.", "建议要求模型只返回最终文本。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) + Text(t("Ask for only the rewritten text, with no explanation.", "建议注明:只返回改写后的文字。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) Spacer() if promptDestination == .secondary { - Button(t("Copy first prompt", "复制第一语言提示词")) { model.settings.secondaryPrompt = model.settings.prompt } + Button(t("Copy main instructions", "复制要求")) { model.settings.secondaryPrompt = model.settings.prompt } } Button(t("Restore default", "恢复默认")) { selectedPrompt.wrappedValue = AppSettings.defaultPrompt } } - DisclosureGroup(t("Effective prompt preview", "实际提示词预览")) { + DisclosureGroup(t("View full instructions", "查看全文")) { Text(model.settings.effectivePrompt(for: promptDestination)) .font(.system(size: 12, design: .monospaced)) .textSelection(.enabled).frame(maxWidth: .infinity, alignment: .leading) @@ -303,14 +301,12 @@ public struct SettingsView: View { if model.supportsFocusedInput { SayoCard { sectionLabel(t("REPLACEMENT", "替换方式")) - toggleRow(t("Character-by-character replacement", "逐字替换动画"), isOn: $model.settings.inputAnimationEnabled, detail: t( - "Reveal whole-input replacements gradually in supported apps. Selected text and terminal drafts are replaced instantly. Respects macOS Reduce Motion.", - "在支持的应用中逐字显示整段替换结果。选区和终端草稿仍一次性回填,并遵循 macOS 的“减少动态效果”设置。" + toggleRow(t("Show text gradually", "逐字显示"), isOn: $model.settings.inputAnimationEnabled, detail: t( + "Show whole-input replacements gradually where supported.\nSelected text and terminal drafts are replaced at once.\nFollows the macOS Reduce Motion setting.", "支持时,整段结果逐字显示。\n选中文字和终端草稿直接替换。\n跟随系统“减少动态效果”设置。" )) Divider() - toggleRow(t("Copy/Paste compatibility fallback", "复制/粘贴兼容模式"), isOn: $model.settings.copyPasteCompatibilityEnabled, detail: t( - "For apps whose input cannot be read normally. An explicit shortcut copies the current selection, then pastes the rewrite back after checking the app and window.", - "用于无法正常读取输入框的应用。快捷键会复制当前选区,并在核对应用和窗口后粘贴改写结果。" + toggleRow(t("Use copy and paste", "复制粘贴"), isOn: $model.settings.copyPasteCompatibilityEnabled, detail: t( + "For apps where Sayo cannot read text directly.\nSelect text, then press your shortcut.\nSayo checks the app and window before pasting the result.", "用于无法直接读取文字的应用。\n先选中文字,再按快捷键。\n核对应用和窗口后,粘贴结果。" )) } } @@ -324,12 +320,12 @@ public struct SettingsView: View { SayoCard { HStack(spacing: 6) { let mode = model.settings.mode.title(language: model.settings.interfaceLanguage) - Text(t("Available actions follow the working mode: \(mode).", "可用操作随工作模式变化,当前为“\(mode)”。")) - pageLink(t("Change", "更改"), to: .rewriting) + Text(t("Current mode: \(mode).\nAvailable shortcuts depend on this mode.", "当前方式:\(mode)。\n可设按键随操作方式变化。")) + pageLink(t("Change mode", "更改方式"), to: .rewriting) }.font(.system(size: 11)).foregroundStyle(SayoStyle.muted) if model.settings.mode.showsInvokeShortcut { Divider() - shortcutRow(t("Invoke Sayo", "唤起 Sayo"), shortcut: $model.settings.invokeShortcut) + shortcutRow(t("Start rewriting", "开始改写"), shortcut: $model.settings.invokeShortcut) } if model.settings.mode.showsCopyShortcut { Divider() @@ -337,12 +333,12 @@ public struct SettingsView: View { } Divider() shortcutRow( - model.settings.mode == .silent ? t("Rewrite and replace", "改写并替换") : t("Replace result", "替换结果"), + model.settings.mode == .silent ? t("Rewrite and replace", "直接替换") : t("Replace original", "替换原文"), shortcut: $model.settings.replaceShortcut ) Divider() - shortcutRow(t("Translate to second language", "翻译为第二语言"), shortcut: $model.settings.secondaryShortcut) - Text(t("Unset by default. Only this shortcut starts a second-language translation; it follows the working mode.", "默认未设置。仅此快捷键可触发第二语言翻译,并遵循工作模式。")) + shortcutRow(t("Translate to other language", "另一语言"), shortcut: $model.settings.secondaryShortcut) + Text(t("Not set by default.\nOnly this shortcut translates into your other language.\nIt follows the same rewrite mode as your main language.", "默认未设置。\n仅此按键可翻译成另一语言。\n操作方式与常用语言相同。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) } } @@ -368,8 +364,8 @@ public struct SettingsView: View { private var terminal: some View { Group { SayoCard { - sectionLabel(t("SHELL INTEGRATION", "Shell 集成")) - Text(t("Rewrite commands with your Sayo shortcut.", "使用 Sayo 快捷键改写命令。")) + sectionLabel(t("Rewrite commands", "命令改写")) + Text(t("Press your Sayo shortcut to rewrite a command as you type.", "按快捷键,改写正在输入的命令。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) ForEach(TerminalShell.allCases) { shell in Divider() @@ -382,9 +378,8 @@ public struct SettingsView: View { } } SayoCard { - sectionLabel(t("CLI EDITORS", "CLI 编辑器")) - Text(t("Install Sayo for each CLI whose drafts you want to rewrite. Restart your terminal after installation for the integration to take effect.", - "为需要使用 Sayo 改写草稿的 CLI 安装集成。安装后需要重启终端才能生效。")) + sectionLabel(t("Rewrite drafts", "草稿改写")) + Text(t("Install draft rewriting for each tool you use below.\nRestart your terminal after installation.", "为下列工具安装草稿改写功能。\n安装后,重启终端即可使用。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) ForEach(CLIEditorProgram.allCases, id: \.self) { program in Divider() @@ -406,7 +401,7 @@ public struct SettingsView: View { HStack { VStack(alignment: .leading, spacing: 3) { Text(name).font(.system(size: 13, weight: .medium)) - Text(installed ? t("Installed", "已安装") : t("Default behavior", "默认行为")) + Text(installed ? t("Installed", "已安装") : t("Not installed", "未安装")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) } Spacer() @@ -422,12 +417,11 @@ public struct SettingsView: View { Group { SayoCard { VStack(alignment: .leading, spacing: 10) { - Text(t("Change how you say it,\nnot what you mean.", "改变表达,\n不改变你想表达的。")) + Text(t("New words. Same meaning.", "换种说法,心意如初。")) .font(.system(size: 28, weight: .semibold)) .accessibilityIdentifier("about-slogan") Text(t( - "You don't have to learn before you begin writing. You truly learn through the act of writing, again and again.", - "你不必先学会,才开始落笔,你会在不断书写的过程中,真正学会。" + "Start writing. Get better as you go.", "从开始写,到越写越好。" )) .font(.system(size: 14)) .foregroundStyle(SayoStyle.muted) @@ -449,45 +443,42 @@ public struct SettingsView: View { } } SayoCard { - sectionLabel(t("UPDATES", "更新")) - Toggle(t("Automatically download updates", "自动下载更新"), isOn: $model.settings.automaticallyDownloadsUpdates) + sectionLabel(t("Software updates", "软件更新")) + Toggle(t("Download automatically", "自动下载"), isOn: $model.settings.automaticallyDownloadsUpdates) .toggleStyle(.checkbox) .accessibilityIdentifier("automatically-download-updates") - Text(t("Download ahead of time. Install when ready, or when you quit Sayo.", "提前下载更新,准备好后可点击更新,或在退出 Sayo 时安装。")) + Text(t("Download updates ahead of time.\nInstall now, or when you quit Sayo.", "提前下载新版。\n可立即安装,或退出时安装。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) Divider() - Toggle(t("Automatically check for updates", "自动检查更新"), isOn: $model.settings.automaticallyChecksForUpdates) + Toggle(t("Check automatically", "自动检查"), isOn: $model.settings.automaticallyChecksForUpdates) .toggleStyle(.checkbox) .accessibilityIdentifier("automatically-check-updates") - Text(t("Check when Sayo opens, at most once an hour. Manual checks always run immediately.", "打开 Sayo 时检查,每小时最多自动检查一次。手动检查始终立即执行。")) + Text(t("Check on startup, at most once an hour.\nClick Check for Updates to check immediately.", "启动时检查,每小时最多一次。\n点击“检查更新”可立即检查。")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) } SayoCard { - Text(t("QUESTIONS & ANSWERS", "问与答")) + Text(t("Common questions", "常见问题")) .font(.system(size: 10, weight: .semibold)).tracking(1.3) aboutQuestion( - t("Where does the icon come from?", "图标的来源?"), + t("The icon's story", "图标故事"), answer: t( - "The icon is a little chameleon. Among nature's light, shadows, and greenery, it quietly changes its appearance, but it is still a little chameleon.", - "图标是一只小变色龙,在大自然的光影和草木之间,它会悄悄改变自己的外表,但这不影响它依然是一只小变色龙" + "The icon is a little chameleon.\nIts appearance changes. It stays itself.", "图标是一只小变色龙。\n外表会变,自己不变。" ), identifier: "about-question-icon" ) Divider() aboutQuestion( - t("How is my data privacy protected?", "我的数据隐私如何保护"), + t("Your text and privacy", "文字隐私"), answer: t( - "Sayo is open source, and API keys are not saved in its configuration. Text you translate is sent to the model you configure, so that model's privacy policy applies. You can consider a local offline model, such as Chrome's built-in Gemini Nano or Hy-MT2-1.8B; both work well.", - "Sayo 是开源的,并且配置里不会保存 API KEY。翻译的内容会发送给用户配置的模型,所以遵循对应模型的隐私政策。可以考虑用本地的离线模型,例如Chrome自带的Gemini Nano,或者 Hy-MT2-1.8B,都有不错的效果。" + "Sayo's source code is public.\nKeys are not saved in the settings file.\nYour chosen service processes your text.\nThat service's privacy policy applies.\nYou can also choose a service that runs on your Mac.", "Sayo 的代码公开可查。\n设置文件不保存密钥。\n文字会交给你选择的服务处理。\n隐私规则以该服务的说明为准。\n也可选择在本机处理的服务。" ), identifier: "about-question-privacy" ) Divider() aboutQuestion( - t("Does long-term use cost much?", "长期使用这个的话,费用高吗?"), + t("Usage costs", "使用费用"), answer: t( - "If you choose the qwen-3.7-flash model, one million input tokens cost only ¥0.2, and each translation costs about ¥0.00003. At a normal typing pace, the estimated cost is less than ¥1 per year, making it exceptionally affordable.\n\nIf you want a completely free model whose data never leaves your computer, we recommend downloading the open-source Hy-MT2-1.8B Q4_K_M model. Once running, it uses very little memory and can keep translation times to around one second.", - "假设选择的是 qwen-3.7-flash 模型,每百万 token 的输入才0.2元,每次翻译大约花费 0.00003 元,估算下来正常打字使用的话 1 年不到 1 块钱,可以说非常非常划算了。\n\n如果想要完全免费且数据不离开电脑的模型,推荐下载 Hy-MT2-1.8B Q4_K_M 这个开源模型,运行之后很低的内存占用,且翻译速度可以保持在大约1秒内。" + "Costs depend on your chosen service and how much you use it.\nCheck that service's current pricing.\nYou can also choose a service that runs on your Mac.", "费用取决于所选服务和用量。\n具体价格请查看服务商说明。\n也可选择在本机处理的服务。" ), identifier: "about-question-cost" ) @@ -585,14 +576,14 @@ private enum SettingsPage: String, CaseIterable, Identifiable { func title(language: InterfaceLanguage) -> String { switch self { - case .general: return language.text("General", "通用") - case .model: return language.text("Language Model", "语言模型") - case .rewriting: return language.text("Rewriting", "改写") + case .general: return language.text("Basics", "基本设置") + case .model: return language.text("Text services", "翻译服务") + case .rewriting: return language.text("Rewriting", "改写设置") case .shortcuts: return language.text("Shortcuts", "快捷键") - case .appAccess: return language.text("App Access", "应用范围") + case .appAccess: return language.text("App access", "使用范围") case .terminal: return language.text("Terminal", "终端") - case .about: return language.text("About Sayo", "关于 Sayo") - case .diagnostics: return language.text("Quick Troubleshooting", "快速排查") + case .about: return language.text("About", "关于") + case .diagnostics: return language.text("Troubleshooting", "问题排查") } } var symbol: String { @@ -609,14 +600,14 @@ private enum SettingsPage: String, CaseIterable, Identifiable { } func subtitle(language: InterfaceLanguage) -> String { switch self { - case .general: return language.text("Make Sayo feel at home in your workflow.", "让语言和日常习惯,都按你的方式来。") - case .model: return language.text("Choose the model behind your words.", "选择你的模型,连接更自然的表达。") - case .rewriting: return language.text("Fine-tune how your thoughts become words.", "调整改写方式,让每次表达更贴近你的习惯。") - case .shortcuts: return language.text("Your favorite actions, a keystroke away.", "把常用操作,变成顺手的快捷键。") - case .appAccess: return language.text("Choose where Sayo lends a hand.", "选择 Sayo 可以帮忙的应用。") - case .terminal: return language.text("Bring clearer writing to your command line.", "在终端与命令行工具中,继续流畅表达。") - case .about: return language.text("A small companion for your words.", "一个安静陪伴你表达的小工具。") - case .diagnostics: return language.text("Connection status and recent activity, in one place.", "查看运行状态,快速定位问题。") + case .general: return language.text("Set your languages and everyday preferences.", "设置语言和使用习惯。") + case .model: return language.text("Choose a service to process your text.", "选择处理文字的服务。") + case .rewriting: return language.text("Choose how to rewrite and replace text.", "设置如何改写和替换文字。") + case .shortcuts: return language.text("Use shortcuts for everyday actions.", "按快捷键,完成常用操作。") + case .appAccess: return language.text("Choose which apps can use Sayo.", "选择在哪些应用中使用。") + case .terminal: return language.text("Rewrite commands and drafts in your terminal.", "在终端里改写命令和草稿。") + case .about: return language.text("View the version, updates, and author information.", "查看版本、更新和作者信息。") + case .diagnostics: return language.text("View activity and find out why an action failed.", "查看使用记录,查找失败原因。") } } } @@ -632,11 +623,11 @@ struct ModelConfigurationView: View { VStack(alignment: .leading, spacing: 18) { if showsOnboardingGuide { onboardingGuide } HStack(spacing: 8) { - Text(t("\(model.configuredModelProfiles.count) saved models", "\(model.configuredModelProfiles.count) 个已配置模型")) + Text(t("\(model.configuredModelProfiles.count) services added", "已添加 \(model.configuredModelProfiles.count) 个服务")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) Spacer(minLength: 8) Button { showingProviderPicker = true } label: { - Label(t("Add provider", "新增供应商"), systemImage: "plus") + Label(t("Add service", "添加服务"), systemImage: "plus") } .buttonStyle(SayoButtonStyle(prominent: true)) .accessibilityIdentifier("add-model-profile") @@ -648,11 +639,11 @@ struct ModelConfigurationView: View { } } Button { model.openModelEditorAction?(model.settings.activeModelProfileID) } label: { - Label(t("Edit", "编辑"), systemImage: "pencil") + Label(t("Edit service", "编辑服务"), systemImage: "pencil") } .accessibilityIdentifier("edit-model-profile") Button(role: .destructive) { confirmingDeletion = true } label: { - Label(t("Delete", "删除"), systemImage: "trash") + Label(t("Delete service", "删除服务"), systemImage: "trash") } .disabled(!model.configuredModelProfiles.contains { $0.id == model.settings.activeModelProfileID }) .accessibilityIdentifier("delete-model-profile") @@ -663,17 +654,17 @@ struct ModelConfigurationView: View { HStack(spacing: 14) { ProviderBadge(provider: model.settings.llm.provider, size: 44) VStack(alignment: .leading, spacing: 5) { - Text(t("Current provider", "当前供应商")) + Text(t("Current service", "当前服务")) .font(.system(size: 11)).foregroundStyle(SayoStyle.muted) Text(currentProfileName).font(.system(size: 19, weight: .semibold)) } Spacer(minLength: 8) - switchHint(t("Click to switch provider", "点击切换供应商")) + switchHint(t("Switch service", "切换服务")) } .contentShape(Rectangle()) } .buttonStyle(.plain) - .accessibilityLabel(t("Switch provider", "切换供应商")) + .accessibilityLabel(t("Switch service", "切换服务")) .accessibilityValue(currentProfileName) .accessibilityIdentifier("switch-model-profile") .popover(isPresented: $showingProviderSwitcher, arrowEdge: .bottom) { @@ -691,12 +682,12 @@ struct ModelConfigurationView: View { .font(.system(size: 12)).foregroundStyle(SayoStyle.muted) .frame(width: 96, alignment: .leading) Text(model.settings.llm.model.isEmpty - ? t("No model selected", "尚未选择模型") : model.settings.llm.model) + ? t("No model selected", "未选模型") : model.settings.llm.model) .font(.system(size: 14, weight: .medium, design: .monospaced)) .fixedSize(horizontal: false, vertical: true) Spacer(minLength: 8) if canSwitchModel { - switchHint(t("Click to switch model", "点击切换模型")) + switchHint(t("Switch model", "切换模型")) } } .contentShape(Rectangle()) @@ -717,38 +708,38 @@ struct ModelConfigurationView: View { } } } - .confirmationDialog(t("Delete this model profile?", "删除当前模型配置?"), isPresented: $confirmingDeletion) { - Button(t("Delete model profile", "删除模型配置"), role: .destructive) { + .confirmationDialog(t("Delete service?", "删除服务"), isPresented: $confirmingDeletion) { + Button(t("Confirm deletion", "确认删除"), role: .destructive) { _ = model.deleteModelProfile(model.settings.activeModelProfileID) } } message: { - Text(t("Its settings and API key will be removed.", "此配置及其 API Key 将被移除。")) + Text(t("This removes the service's settings and key.", "将删除此服务的设置和密钥。")) } SayoCard { HStack { - Text(t("Connection", "接入信息")).font(.system(size: 13, weight: .semibold)) + Text(t("Connection settings", "连接设置")).font(.system(size: 13, weight: .semibold)) Spacer() if let website = model.settings.llm.provider.homepageURL { Link(destination: website) { - Label(t("Provider website", "供应商官网"), systemImage: "arrow.up.right") + Label(t("Official website", "官方网站"), systemImage: "arrow.up.right") .font(.system(size: 11)) } } } if model.settings.llm.provider != .chromeNano { - detailRow(t("API format", "API 格式"), model.settings.llm.resolvedAPIFormat.displayName) + detailRow(t("Connection type", "连接类型"), model.settings.llm.resolvedAPIFormat.displayName) HStack(alignment: .center, spacing: 18) { - Text("Base URL").font(.system(size: 12)).foregroundStyle(SayoStyle.muted) + Text(t("Service address", "服务地址")).font(.system(size: 12)).foregroundStyle(SayoStyle.muted) .frame(width: 96, alignment: .leading) if model.settings.llm.baseURL.isEmpty { - Text(t("Not configured", "尚未配置")).font(.system(size: 12)).foregroundStyle(SayoStyle.muted) + Text(t("No address entered", "未填地址")).font(.system(size: 12)).foregroundStyle(SayoStyle.muted) } else { SayoCopyValue(value: model.settings.llm.baseURL, language: model.settings.interfaceLanguage) } } - detailRow("API Key", model.apiKey.isEmpty ? t("Not set", "未填写") : t("Stored in Keychain", "已保存至钥匙串")) + detailRow(t("Service key", "服务密钥"), model.apiKey.isEmpty ? t("No key entered", "未填密钥") : t("Saved in Keychain.", "已存入系统钥匙串。")) } else { - detailRow(t("Connection", "连接方式"), t("On-device in Chrome · No API key", "Chrome 本机推理 · 无需 API Key")) + detailRow(t("Connection", "连接方式"), t("Processed on this Mac. No key needed.", "在本机处理,无需密钥。")) } } SayoCard { ModelConnectionTestView(model: model) } @@ -866,7 +857,7 @@ private final class RecorderButton: NSButton { func update(_ shortcut: Shortcut?) { value = shortcut; if !recording { updateTitle() } } @objc private func record() { recording = true - title = language.text("Press shortcut…", "请按快捷键…") + title = language.text("Press shortcut…", "按下按键") window?.makeFirstResponder(self) } override func keyDown(with event: NSEvent) { @@ -881,7 +872,7 @@ private final class RecorderButton: NSButton { } let flags = event.modifierFlags.intersection(.deviceIndependentFlagsMask) guard !flags.intersection([.command, .control, .option]).isEmpty else { - title = language.text("Use ⌘, ⌃ or ⌥", "请使用 ⌘、⌃ 或 ⌥") + title = language.text("Use ⌘, ⌃ or ⌥", "搭配 ⌘、⌃ 或 ⌥") return } let value = Shortcut(keyCode: UInt32(event.keyCode), command: flags.contains(.command), option: flags.contains(.option), control: flags.contains(.control), shift: flags.contains(.shift)) @@ -914,7 +905,7 @@ private struct ShortcutControls: View { }.buttonStyle(.plain).foregroundStyle(SayoStyle.muted) .disabled(!isSet) .accessibilityLabel(language.text("Clear ", "清除 ") + label + language.text(" shortcut", " 快捷键")) - .help(language.text("Clear shortcut", "清除快捷键")) + .help(language.text("Clear shortcut", "清除按键")) } } } diff --git a/Tests/SayoUITests/AppUpdateModelTests.swift b/Tests/SayoUITests/AppUpdateModelTests.swift index 46181b8..114ffce 100644 --- a/Tests/SayoUITests/AppUpdateModelTests.swift +++ b/Tests/SayoUITests/AppUpdateModelTests.swift @@ -23,7 +23,7 @@ import SayoUI let model = AppViewModel(settings: .init()) model.settings.interfaceLanguage = .simplifiedChinese XCTAssertFalse(model.canRequestUpdateCheck) - XCTAssertEqual(model.updateActionTitle, "更新不可用") + XCTAssertEqual(model.updateActionTitle, "暂不可用") } func testFailedCheckCanBeRetriedButAnActiveCheckCannotBeDuplicated() { @@ -43,8 +43,8 @@ import SayoUI func testButtonReflectsDownloadAndInstallStagesInBothLanguages() { let model = AppViewModel(settings: .init()) - for (language, download, install) in [(InterfaceLanguage.english, "Download Update", "Update Now"), - (.simplifiedChinese, "下载更新", "点击更新")] { + for (language, download, install) in [(InterfaceLanguage.english, "Download update", "Update now"), + (.simplifiedChinese, "下载新版", "立即更新")] { model.settings.interfaceLanguage = language model.updateState = .available(version: "1.0.0") XCTAssertEqual(model.updateActionTitle, download) @@ -58,15 +58,15 @@ import SayoUI let model = AppViewModel(settings: .init()) model.settings.interfaceLanguage = .simplifiedChinese model.updateState = .checking - XCTAssertEqual(model.updateActionTitle, "检查更新中") + XCTAssertEqual(model.updateActionTitle, "检查中") model.updateState = .downloading(version: "1.0.0", progress: 0.4) XCTAssertEqual(model.updateActionTitle, "下载中 40%") XCTAssertFalse(model.canRequestUpdateCheck) model.updateState = .upToDate - XCTAssertEqual(model.updateActionTitle, "已是最新版本") + XCTAssertEqual(model.updateActionTitle, "已是最新") XCTAssertTrue(model.canRequestUpdateCheck) model.updateState = .failed("Offline") - XCTAssertEqual(model.updateActionTitle, "更新失败 · 重试") + XCTAssertEqual(model.updateActionTitle, "重试更新") XCTAssertTrue(model.canRequestUpdateCheck) } diff --git a/updates/plain-settings-copy-20261008.json b/updates/plain-settings-copy-20261008.json new file mode 100644 index 0000000..4e9c636 --- /dev/null +++ b/updates/plain-settings-copy-20261008.json @@ -0,0 +1,5 @@ +{ + "bump": "patch", + "en": ["Simplified settings menus, controls, and explanations in English and Simplified Chinese, with clearer service setup, privacy notices, and usage cost information."], + "zh-CN": ["简化中英文设置菜单、按钮和说明,让服务连接、文字隐私及使用费用更容易理解。"] +} From bff5810878b2fad66ac63fbaafa90372991c5c26 Mon Sep 17 00:00:00 2001 From: Riko Date: Thu, 8 Oct 2026 19:32:48 -0700 Subject: [PATCH 2/2] Use bundled LobeHub SVG provider icons --- Sources/SayoUI/ProviderIconAssets.swift | 38 +++++++++++++++++++ .../ProviderIcons/LobeIcons-LICENSE.txt | 21 ++++++++++ .../ProviderIcons/ProviderIcons-README.md | 19 ++++++++++ .../Resources/ProviderIcons/anthropic.svg | 1 + .../ProviderIcons/deepseek-color.svg | 1 + .../Resources/ProviderIcons/doubao-color.svg | 1 + .../Resources/ProviderIcons/gemini-color.svg | 1 + .../ProviderIcons/internlm-color.svg | 1 + .../SayoUI/Resources/ProviderIcons/kimi.svg | 1 + .../SayoUI/Resources/ProviderIcons/openai.svg | 1 + .../Resources/ProviderIcons/opencode.svg | 1 + .../ProviderIcons/openrouter-color.svg | 1 + .../Resources/ProviderIcons/qwen-color.svg | 1 + .../ProviderIcons/siliconcloud-color.svg | 1 + .../Resources/ProviderIcons/zhipu-color.svg | 1 + Sources/SayoUI/SayoDesignSystem.swift | 20 +++++++--- .../SayoUITests/ProviderIconAssetsTests.swift | 23 +++++++++++ updates/lobehub-provider-icons-20261008.json | 5 +++ 18 files changed, 133 insertions(+), 5 deletions(-) create mode 100644 Sources/SayoUI/ProviderIconAssets.swift create mode 100644 Sources/SayoUI/Resources/ProviderIcons/LobeIcons-LICENSE.txt create mode 100644 Sources/SayoUI/Resources/ProviderIcons/ProviderIcons-README.md create mode 100644 Sources/SayoUI/Resources/ProviderIcons/anthropic.svg create mode 100644 Sources/SayoUI/Resources/ProviderIcons/deepseek-color.svg create mode 100644 Sources/SayoUI/Resources/ProviderIcons/doubao-color.svg create mode 100644 Sources/SayoUI/Resources/ProviderIcons/gemini-color.svg create mode 100644 Sources/SayoUI/Resources/ProviderIcons/internlm-color.svg create mode 100644 Sources/SayoUI/Resources/ProviderIcons/kimi.svg create mode 100644 Sources/SayoUI/Resources/ProviderIcons/openai.svg create mode 100644 Sources/SayoUI/Resources/ProviderIcons/opencode.svg create mode 100644 Sources/SayoUI/Resources/ProviderIcons/openrouter-color.svg create mode 100644 Sources/SayoUI/Resources/ProviderIcons/qwen-color.svg create mode 100644 Sources/SayoUI/Resources/ProviderIcons/siliconcloud-color.svg create mode 100644 Sources/SayoUI/Resources/ProviderIcons/zhipu-color.svg create mode 100644 Tests/SayoUITests/ProviderIconAssetsTests.swift create mode 100644 updates/lobehub-provider-icons-20261008.json diff --git a/Sources/SayoUI/ProviderIconAssets.swift b/Sources/SayoUI/ProviderIconAssets.swift new file mode 100644 index 0000000..6d8240d --- /dev/null +++ b/Sources/SayoUI/ProviderIconAssets.swift @@ -0,0 +1,38 @@ +import AppKit +import SayoCore + +/// LobeHub artwork is bundled locally and decoded as native vector images. +enum ProviderIconAssets { + static func resourceName(for provider: ProviderKind) -> String? { + switch provider { + case .deepSeek: return "deepseek-color" + case .doubao: return "doubao-color" + case .gemini, .chromeNano: return "gemini-color" + case .internAI: return "internlm-color" + case .qwen: return "qwen-color" + case .moonshot: return "kimi" + case .zhipu: return "zhipu-color" + case .siliconFlow: return "siliconcloud-color" + case .openRouter: return "openrouter-color" + case .openCode: return "opencode" + case .openAICompatible: return "openai" + case .anthropic: return "anthropic" + case .localModel, .custom, .magpie: return nil + } + } + + static func image(for provider: ProviderKind) -> NSImage? { + guard let name = resourceName(for: provider) else { return nil } + return images[name] + } + + private static let images: [String: NSImage] = { + let names = Set(ProviderKind.allCases.compactMap { resourceName(for: $0) }) + return Dictionary(uniqueKeysWithValues: names.compactMap { name in + guard let url = Bundle.module.url(forResource: name, withExtension: "svg"), + let image = NSImage(contentsOf: url) else { return nil } + image.isTemplate = false + return (name, image) + }) + }() +} diff --git a/Sources/SayoUI/Resources/ProviderIcons/LobeIcons-LICENSE.txt b/Sources/SayoUI/Resources/ProviderIcons/LobeIcons-LICENSE.txt new file mode 100644 index 0000000..1dd53d2 --- /dev/null +++ b/Sources/SayoUI/Resources/ProviderIcons/LobeIcons-LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 LobeHub + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Sources/SayoUI/Resources/ProviderIcons/ProviderIcons-README.md b/Sources/SayoUI/Resources/ProviderIcons/ProviderIcons-README.md new file mode 100644 index 0000000..3580606 --- /dev/null +++ b/Sources/SayoUI/Resources/ProviderIcons/ProviderIcons-README.md @@ -0,0 +1,19 @@ +# Provider icons + +Artwork from [LobeHub Icons](https://github.com/lobehub/lobe-icons), +`@lobehub/icons-static-svg` version **1.95.1**, commit +`49a2130df7bfa5eb1b088261bff20a37e2967789`. +See `LobeIcons-LICENSE.txt` for the upstream MIT license. + +These SVGs are bundled for offline use. Native AppKit renders their vector +paths and original colors; no runtime download or third-party renderer is used. + +For macOS CoreSVG compatibility, the upstream `1em` dimensions are replaced +with the viewBox dimensions, the web layout style is removed, and path commands +and arguments are separated by spaces (using svgpath 2.6.0). This avoids CoreSVG +misreading compressed arc flags. Geometry, gradients and colors are unchanged. + +Gemini Nano uses the Gemini mark. Intern-AI uses InternLM, Moonshot uses Kimi, +and SiliconFlow uses the upstream `siliconcloud-color` mark. Kimi uses the +monochrome variant for contrast on the light settings background. Local models, +custom services and Magpie retain their existing system icons. diff --git a/Sources/SayoUI/Resources/ProviderIcons/anthropic.svg b/Sources/SayoUI/Resources/ProviderIcons/anthropic.svg new file mode 100644 index 0000000..8e8fec6 --- /dev/null +++ b/Sources/SayoUI/Resources/ProviderIcons/anthropic.svg @@ -0,0 +1 @@ +Anthropic diff --git a/Sources/SayoUI/Resources/ProviderIcons/deepseek-color.svg b/Sources/SayoUI/Resources/ProviderIcons/deepseek-color.svg new file mode 100644 index 0000000..947af51 --- /dev/null +++ b/Sources/SayoUI/Resources/ProviderIcons/deepseek-color.svg @@ -0,0 +1 @@ +DeepSeek diff --git a/Sources/SayoUI/Resources/ProviderIcons/doubao-color.svg b/Sources/SayoUI/Resources/ProviderIcons/doubao-color.svg new file mode 100644 index 0000000..a68a157 --- /dev/null +++ b/Sources/SayoUI/Resources/ProviderIcons/doubao-color.svg @@ -0,0 +1 @@ +Doubao diff --git a/Sources/SayoUI/Resources/ProviderIcons/gemini-color.svg b/Sources/SayoUI/Resources/ProviderIcons/gemini-color.svg new file mode 100644 index 0000000..dcf3b22 --- /dev/null +++ b/Sources/SayoUI/Resources/ProviderIcons/gemini-color.svg @@ -0,0 +1 @@ +Gemini diff --git a/Sources/SayoUI/Resources/ProviderIcons/internlm-color.svg b/Sources/SayoUI/Resources/ProviderIcons/internlm-color.svg new file mode 100644 index 0000000..aafa3db --- /dev/null +++ b/Sources/SayoUI/Resources/ProviderIcons/internlm-color.svg @@ -0,0 +1 @@ +InternLM diff --git a/Sources/SayoUI/Resources/ProviderIcons/kimi.svg b/Sources/SayoUI/Resources/ProviderIcons/kimi.svg new file mode 100644 index 0000000..d67e665 --- /dev/null +++ b/Sources/SayoUI/Resources/ProviderIcons/kimi.svg @@ -0,0 +1 @@ +Kimi diff --git a/Sources/SayoUI/Resources/ProviderIcons/openai.svg b/Sources/SayoUI/Resources/ProviderIcons/openai.svg new file mode 100644 index 0000000..d4dbaf8 --- /dev/null +++ b/Sources/SayoUI/Resources/ProviderIcons/openai.svg @@ -0,0 +1 @@ +OpenAI diff --git a/Sources/SayoUI/Resources/ProviderIcons/opencode.svg b/Sources/SayoUI/Resources/ProviderIcons/opencode.svg new file mode 100644 index 0000000..eee4672 --- /dev/null +++ b/Sources/SayoUI/Resources/ProviderIcons/opencode.svg @@ -0,0 +1 @@ +opencode diff --git a/Sources/SayoUI/Resources/ProviderIcons/openrouter-color.svg b/Sources/SayoUI/Resources/ProviderIcons/openrouter-color.svg new file mode 100644 index 0000000..ed6d314 --- /dev/null +++ b/Sources/SayoUI/Resources/ProviderIcons/openrouter-color.svg @@ -0,0 +1 @@ +OpenRouter diff --git a/Sources/SayoUI/Resources/ProviderIcons/qwen-color.svg b/Sources/SayoUI/Resources/ProviderIcons/qwen-color.svg new file mode 100644 index 0000000..5dd5eb1 --- /dev/null +++ b/Sources/SayoUI/Resources/ProviderIcons/qwen-color.svg @@ -0,0 +1 @@ +Qwen diff --git a/Sources/SayoUI/Resources/ProviderIcons/siliconcloud-color.svg b/Sources/SayoUI/Resources/ProviderIcons/siliconcloud-color.svg new file mode 100644 index 0000000..9174aaa --- /dev/null +++ b/Sources/SayoUI/Resources/ProviderIcons/siliconcloud-color.svg @@ -0,0 +1 @@ +SiliconCloud diff --git a/Sources/SayoUI/Resources/ProviderIcons/zhipu-color.svg b/Sources/SayoUI/Resources/ProviderIcons/zhipu-color.svg new file mode 100644 index 0000000..b37af64 --- /dev/null +++ b/Sources/SayoUI/Resources/ProviderIcons/zhipu-color.svg @@ -0,0 +1 @@ +Zhipu diff --git a/Sources/SayoUI/SayoDesignSystem.swift b/Sources/SayoUI/SayoDesignSystem.swift index a655333..93f8134 100644 --- a/Sources/SayoUI/SayoDesignSystem.swift +++ b/Sources/SayoUI/SayoDesignSystem.swift @@ -164,11 +164,21 @@ struct ProviderBadge: View { } } var body: some View { - Image(systemName: symbol).font(.system(size: size * 0.46, weight: .medium)) - .foregroundStyle(color) - .frame(width: size, height: size) - .background(color.opacity(0.085), in: RoundedRectangle(cornerRadius: size * 0.28)) - .accessibilityHidden(true) + Group { + if let image = ProviderIconAssets.image(for: provider) { + Image(nsImage: image) + .resizable() + .scaledToFit() + .frame(width: size * 0.62, height: size * 0.62) + } else { + Image(systemName: symbol) + .font(.system(size: size * 0.46, weight: .medium)) + .foregroundStyle(color) + } + } + .frame(width: size, height: size) + .background(color.opacity(0.085), in: RoundedRectangle(cornerRadius: size * 0.28)) + .accessibilityHidden(true) } } diff --git a/Tests/SayoUITests/ProviderIconAssetsTests.swift b/Tests/SayoUITests/ProviderIconAssetsTests.swift new file mode 100644 index 0000000..125e40d --- /dev/null +++ b/Tests/SayoUITests/ProviderIconAssetsTests.swift @@ -0,0 +1,23 @@ +import AppKit +import XCTest +import SayoCore +@testable import SayoUI + +final class ProviderIconAssetsTests: XCTestCase { + func testBundledProviderArtworkDecodesAsNonTemplateVectors() throws { + for provider in ProviderKind.allCases where ProviderIconAssets.resourceName(for: provider) != nil { + let image = try XCTUnwrap(ProviderIconAssets.image(for: provider), provider.rawValue) + XCTAssertFalse(image.isTemplate, provider.rawValue) + XCTAssertEqual(image.size, NSSize(width: 24, height: 24), provider.rawValue) + XCTAssertTrue(image.representations.contains { + String(describing: type(of: $0)).contains("SVG") + }, "Expected native SVG artwork for \(provider.rawValue)") + } + } + + func testGenericServicesKeepSystemIconFallback() { + for provider in [ProviderKind.localModel, .custom, .magpie] { + XCTAssertNil(ProviderIconAssets.image(for: provider)) + } + } +} diff --git a/updates/lobehub-provider-icons-20261008.json b/updates/lobehub-provider-icons-20261008.json new file mode 100644 index 0000000..6943e87 --- /dev/null +++ b/updates/lobehub-provider-icons-20261008.json @@ -0,0 +1,5 @@ +{ + "bump": "patch", + "en": ["Use crisp LobeHub SVG logos for supported model providers in settings and service editors."], + "zh-CN": ["大模型设置和服务编辑窗口采用 LobeHub SVG 品牌图标,缩放更清晰。"] +}