Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ brew upgrade --cask --greedy riko2chen/sayo/sayo
## 功能

- **原地翻译与润色**:处理中英混输、翻译和语气调整;有选区时处理选中文字,无选区时默认处理整个输入框。
- **预览或直接替换**:手动模式先查看结果,静默模式通过快捷键直接改写。
- **预览或直接替换**:“点击改写”可先查看结果,“直接替换”通过快捷键改写并替换原文。
- **双目标语言**:支持绑定两个快捷键,分别转写成两种不同语言。
- **终端与 CLI**:支持 zsh、bash 4+、fish,以及 Codex CLI、Claude Code 等外部编辑器接入。

Expand Down
22 changes: 10 additions & 12 deletions Sources/SayoApp/SayoApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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 }
}
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down
22 changes: 11 additions & 11 deletions Sources/SayoCore/DiagnosticAnalysis.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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", "旧记录")
}
}
}
Expand Down Expand Up @@ -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) 条事件")
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions Sources/SayoCore/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.", "另一语言的按键不能与其他操作相同。"
)
}
}
Expand Down
15 changes: 7 additions & 8 deletions Sources/SayoUI/AboutAuthorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
Expand Down Expand Up @@ -88,15 +87,15 @@ 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 {
VStack(alignment: .leading, spacing: 16) {
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)
Expand All @@ -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)
}
Expand Down
34 changes: 17 additions & 17 deletions Sources/SayoUI/AppUpdateView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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", "检查更新")
}
}
Expand All @@ -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)")
}
}
}
Expand Down
Loading
Loading