知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.
Swift androidlinuxlive-captionsmacosmeeting-notesmenubar-appsimultaneous-interpretationspeech-recognitionsubtitlesswiftswiftuitranslationwindows
fix(ios): follow system no longer translates a meeting into the language it is already in
wquguru8869dc7bef43
diff --git a/ios/Sources/Cicada/CicadaApp.swift b/ios/Sources/Cicada/CicadaApp.swiftindex bdb5a48..e426e03 100644--- a/ios/Sources/Cicada/CicadaApp.swift+++ b/ios/Sources/Cicada/CicadaApp.swift@@ -67,6 +67,15 @@ enum Pref {return RecordList.pair(s, short: true) ?? ""}+ /// What a meeting in `source` is translated into, as the Mac's `AppSettings.resolvedTarget`:+ /// 跟随系统 is my language, unless they speak it; then the next system language (English UI and+ /// an English meeting would otherwise "translate" English into English).+ static func target(for source: String) -> String {+ let t = UserDefaults.standard.string(forKey: target) ?? "system"+ return t == "system" ? followSystemTarget(source: source, systemLanguages: Locale.preferredLanguages) : t+ }++ /// The reader's own language (纪要's 我的语言).static var targetCode: String {let t = UserDefaults.standard.string(forKey: target) ?? "system"return t == "system" ? myLanguage(systemLanguages: Locale.preferredLanguages) : t@@ -187,7 +196,7 @@ final class AppModel: ObservableObject {searchPath = []tab = .recordsfixes.meetingStarted()- room.start(source: Pref.sourceLang.locale, target: Pref.targetCode, voices: UserDefaults.standard.bool(forKey: Pref.voices),+ room.start(source: Pref.sourceLang.locale, target: Pref.target(for: Pref.sourceLang.code), voices: UserDefaults.standard.bool(forKey: Pref.voices),speaker: Pref.speakerMode)}diff --git a/ios/Sources/Cicada/Debug.swift b/ios/Sources/Cicada/Debug.swiftindex 73e2b4a..e732230 100644--- a/ios/Sources/Cicada/Debug.swift+++ b/ios/Sources/Cicada/Debug.swift@@ -160,6 +160,9 @@ extension AppModel {// A meeting without the microphone or the recognizer, fed lines by `heard:`.RoomListen.silent = arg != "off"case "heard": room.debugHeard(arg)+ case "heardT":+ let p = arg.split(separator: "|", maxSplits: 1).map(String.init)+ if p.count == 2 { room.debugHeard(p[0], translation: p[1]) }case "vocabAdd": // vocabAdd:Morpho=莫拉、莫法 (several lines with "|")let r = vocabulary.importText(arg.replacingOccurrences(of: "|", with: "\n"))debugLog("vocab: added=\(r.added) updated=\(r.updated) skipped=\(r.skipped)")diff --git a/ios/Sources/Cicada/FaceToFace.swift b/ios/Sources/Cicada/FaceToFace.swiftindex fb5b742..2d0a3d7 100644--- a/ios/Sources/Cicada/FaceToFace.swift+++ b/ios/Sources/Cicada/FaceToFace.swift@@ -236,6 +236,7 @@ final class FaceToFace: ObservableObject {let from = lang(side), to = lang(side == .me ? .them : .me)let t = Turn(side: side, said: said, translation: translation)last = t+ problem = ""record(t, from: from, to: to)phase = .speaking(side)turnTask = Task {diff --git a/ios/Sources/Cicada/Importing.swift b/ios/Sources/Cicada/Importing.swiftindex b3f3eb1..9328cc4 100644--- a/ios/Sources/Cicada/Importing.swift+++ b/ios/Sources/Cicada/Importing.swift@@ -15,10 +15,7 @@ import UniformTypeIdentifiersfinal class ImportPrefs: ImportSettings {var importLanguage: String { Pref.sourceLang.locale }var speakerVoices: Bool { UserDefaults.standard.bool(forKey: Pref.voices) }- func resolvedTarget(source: String?) -> String {- UserDefaults.standard.string(forKey: Pref.target).flatMap { $0 == "system" ? nil : $0 }- ?? followSystemTarget(source: source, systemLanguages: Locale.preferredLanguages)- }+ func resolvedTarget(source: String?) -> String { Pref.target(for: source ?? Pref.sourceLang.code) }}enum ImportFiles {diff --git a/ios/Sources/Cicada/LiveViews.swift b/ios/Sources/Cicada/LiveViews.swiftindex 50fc588..5db0db6 100644--- a/ios/Sources/Cicada/LiveViews.swift+++ b/ios/Sources/Cicada/LiveViews.swift@@ -99,7 +99,7 @@ struct ListenBar: View {ForEach(targetLanguages, id: \.code) { Text($0.name).tag($0.code) }} label: { Text("翻译成") }} label: {- Text(verbatim: (hear == "speaker" ? L("外放") + " · " : "") + "\(Pref.sourceName) → \(targetName(Pref.targetCode))")+ Text(verbatim: (hear == "speaker" ? L("外放") + " · " : "") + "\(Pref.sourceName) → \(targetName(Pref.target(for: Pref.sourceLang.code)))").font(.subheadline).foregroundStyle(Ink.secondary).lineLimit(1).minimumScaleFactor(0.75).frame(maxWidth: .infinity, alignment: .leading).frame(minHeight: 44)diff --git a/ios/Sources/Cicada/RoomListen.swift b/ios/Sources/Cicada/RoomListen.swiftindex bd9d1a7..837a139 100644--- a/ios/Sources/Cicada/RoomListen.swift+++ b/ios/Sources/Cicada/RoomListen.swift@@ -327,6 +327,16 @@ final class RoomListen: ObservableObject {handle(Recognition.Piece(text: text, isFinal: true, start: at, end: at + 2, confidence: nil))}+ /// Debug (`heardT:<text>|<translation>`): as `debugHeard`, with the translation given, for+ /// screenshots when no translation service answers.+ func debugHeard(_ text: String, translation: String) {+ debugHeard(text)+ guard let i = lines.lastIndex(where: { $0.src == text }) else { return }+ lines[i].dst = translation+ store.setTranslation(lineID: lines[i].id, translation)+ onLine?(lines[i])+ }+/// `retry`: every provider failed before (Ling busy while Google answers 429): asked again a/// little later, twice at most, as the Mac does.private func translate(_ id: String, _ text: String, retry: Int = 0) {diff --git a/ios/Sources/Cicada/Welcome.swift b/ios/Sources/Cicada/Welcome.swiftindex fbe7194..4732629 100644--- a/ios/Sources/Cicada/Welcome.swift+++ b/ios/Sources/Cicada/Welcome.swift@@ -211,7 +211,7 @@ private struct WelcomeSample: View {} else {Text(sample.played ? L("放完了") : L("约 \(Int(SampleRun.duration.rounded())) 秒")).font(.footnote).foregroundStyle(Ink.secondary)}- Text(verbatim: L("示例会议") + " · " + Pref.pairText("en", Pref.targetCode)).font(.headline).foregroundStyle(Ink.ink)+ Text(verbatim: L("示例会议") + " · " + Pref.pairText("en", Pref.target(for: "en"))).font(.headline).foregroundStyle(Ink.ink)}Spacer(minLength: 8)Button { sample.playing ? model.stopSample() : model.playSample() } label: {@@ -432,7 +432,7 @@ extension AppModel {guard !sample.playing else { return }if !room.isRunning {fixes.meetingStarted()- room.start(source: "en-US", target: Pref.targetCode, voices: UserDefaults.standard.bool(forKey: Pref.voices))+ room.start(source: "en-US", target: Pref.target(for: "en"), voices: UserDefaults.standard.bool(forKey: Pref.voices))}sample.onFinished = { [weak self] inDispatchQueue.main.asyncAfter(deadline: .now() + 2) { self?.stopListening() }