Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

feat: localize the app into English, fix the first sentences, crash-safe recordings and notes language

wquguruccd59f8fb6bc
diff --git a/AGENTS.md b/AGENTS.md
index 25b7fe2..a1db5a6 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -14,7 +14,7 @@ Cicada (知了, formerly Live Subs) is a macOS menu bar app that turns whatever
- Live notes (`NotesEngine`, UI-free): about every 45 s with new lines, one JSON call sends the current notes + new lines (`[L12 02:03 对方] …`) and gets the whole notes back (a meeting name — shown as "<date> <name>" via `Session.displayTitle` unless the user renamed it —, summary, ≤ 8 topics with points and an optional fishbone, conclusions/to-dos with evidence line ids → support counts, terms with misrecognised forms); a bad reply never replaces good notes. A final pass over the whole transcript runs when the meeting ends ("完整版"). Notes are written in the 纪要语言 (`AppModel.notesLanguageCode`): the reader's language by default (the translate-to choice, or Chinese when Chinese is among the system languages), or the meeting's own; one meeting can differ (`notesLanguageFor`, the notes window's "EN → 中" chip, an inline card since a popover closes at once in the non-activating panel; changing it mid-meeting rewrites the notes from scratch, `NotesEngine.rewrite`). The language is stated again at the end of the prompt and in the user message, and a reply not in it (`NotesEngine.written`, CJK share) is retried once on the final pass, otherwise dropped: the final pass has no Chinese notes to follow, and a long English transcript pulls it into English. Stored as `notes` in `session.json`; finished meetings without notes can generate them from the main window. Speak-back voices (`Voices.swift`, settings UI `VoicePicker.swift` on the 同声传译 page): one choice per room language (`speakVoices`, "en" → `ming:US_Emma` / `system:<AVSpeechSynthesisVoice id>` / `clone`). Offered: hand-picked Ming voices (English Emma/George/Charlotte; Chinese 小雅/小棠/小锋/卓然; ja/ko/de/fr/es via Emma/George with `language_id`) and the Mac's best female and male voice; default is Ming's first with a key, else the Mac's. `clone` is the user's own voice: a 8–30 s recording read from a passage in their language (16 kHz WAV + its on-device transcript in `voice/` under Application Support, 0600, out of backups), sent to Ming as `references` with every sentence (~600 KB, first audio ~3 s, ~8 s on a cold call; a foreign language keeps the speaker's accent). Ming's voices fall back to the Mac's voice without a usable key or when the stream fails; previews play on the default output, not the room.0-tts-0.5B`, SSE PCM 24 kHz) through the same key, falling back to the system voice.
- Live notes window (`NotesWindow`): opens at the first words of a meeting (system audio or a talk press; `AppModel.heardSpeech`), or at once when the user picks it; a floating `NSPanel`, `sharingType = .none` (invisible to screen sharing and screenshots), on all Spaces, frame autosaved; < 360 px a card that offers what the notes added since it was collapsed ("收起后新增 …", only when there is something), tabs 纪要 / 文字记录 in between, both side by side from 760 px; a 结束 button while live (asks in an inline strip once there are lines; `AppModel.requestStop` asks with an alert for ⌘R and the panel switch, 继续记录 the default), then an ended strip (final-pass state, 在会议记录中查看, 开始新会议); `FirstClickHostingView` so a click works without focusing the panel first; banners for no key (inline key entry) / invalid key / rate limited. While writing: sound bars before anyone speaks, a spinner with "已听到 N 句" and shimmering placeholders for the first version, an "正在更新" pill and a warm shimmer under the current topic for later updates (`TimelineView`, since the window redraws every second). Transcript: oldest first, follows the newest line plus the sentence still being spoken; following survives content and window height changes, and only a real scroll-wheel/trackpad event (`UserScroll`) followed by scrolling up pauses it and gathers new lines into a "↓ N 句新内容" button; search highlights in place (query plus the notes' misheard forms of a name). Notes carry times: points and conclusions get the time of their first evidence line (`pointTimes`, `NoteItem.t`; carried over when the model echoes a point without evidence), topics show ranges.
- App menu (`AppMenu`): the app is a regular app (name and menus top left, Dock, ⌘Tab) while the main, settings or onboarding window is visible, and an accessory otherwise (`AppDelegate.updateActivationPolicy`). The notes window doesn't count: it is a non-activating panel, so clicking it never takes focus from the meeting app or brings our other windows forward; it becomes key only for its text fields. Opening the app by hand shows the main window (not when started as a login item); the Dock icon brings back whichever windows are open (the main window only when none is); quitting while a meeting with lines is being recorded asks first; exports are a sheet on the window they were asked from. The settings window remembers its frame and last tab (`settingsSection`). Menus: app, 纪要, 显示 (display mode, ⌘1–⌘3 sizes, 始终置顶), 编辑 (standard responder-chain actions, so ⌘V works in fields; ⌘F search), 窗口, 帮助.
-- Meeting records: one folder per meeting, `session.json` + `system.m4a` (+ `mic.m4a`); empty meetings are dropped; export to Markdown, Word (`.docx` via `NSAttributedString`, both starting with the notes) and SRT. Speaker labels are only "对方" (system audio) and "你" (microphone): no diarization yet.
+- Meeting records: one folder per meeting, `session.json` + `system.m4a` (+ `mic.m4a`; recorded as ADTS `system.aac` / `mic.aac`, which survive a crash, and rewrapped to .m4a without re-encoding at the end or at the next launch, `AudioFileWriter.finish`); sentences heard before auto-detection confirms the language are held and recorded once it does (dropped on a switch, which replays them); empty meetings are dropped; export to Markdown, Word (`.docx` via `NSAttributedString`, both starting with the notes) and SRT. Speaker labels are only "对方" (system audio) and "你" (microphone): no diarization yet.
- Shortcuts (`Shortcuts.swift`): talk and subtitle-bar toggle are recorded in settings (`ShortcutField`). A combination must include ⌃ or ⌘ (⌥/⇧ alone types characters; bare F keys are brightness/volume), must not be a system shortcut (`CopySymbolicHotKeys`) or held by another app (Carbon refuses to register it).
- Nothing the user does needs the Terminal. When a feature request fits none of the above, push back before adding UI.
@@ -23,7 +23,7 @@ Cicada (知了, formerly Live Subs) is a macOS menu bar app that turns whatever
- Source of truth: the Design canvases in claude.ai (logo directions, onboarding, auto show/hide) and the app itself.
- Look: light grey ground `#F3F4F6`/`#F6F7F9`, white cards, ink `#15171C`, one accent orange `#E8552B` for "live" (dots, the speaking line, the icon). Text greys `#5A5F6B` / `#6B7080` (they pass 4.5:1 on white).
- Logo B (design: claude.ai/artifact/96R6Md276c3jAS4Mk4Ustn): a cicada's dark eyes and white wings peeking over a white subtitle card that leans 5° and bleeds off the bottom right, on an orange gradient squircle. The geometry (100-unit design space) is in three places kept in step: `CicadaLogo` in `Onboarding.swift` (the in-app `BrandMark` and the one-colour menu bar glyph `BrandImage.menuBar` with a whole card, 40% when paused), its copy in `Sources/LiveSubsIcon` (the app icon) and `site/icon.svg`. After changing it: `scripts/site-images.sh` (site `icon.png`, `og.png`) and `docs/icon.png` (the README's, the app icon's 256 px render).
-- Copy is Chinese, short: one line of grey helper text at most.
+- Copy is Chinese, short: one line of grey helper text at most. The UI also ships in English (`Localization.swift`): the Chinese source text is the key and `Resources/en.lproj/Localizable.strings` holds the English (plurals in `Localizable.stringsdict`). SwiftUI literals (`Text`, `Button`, `.help` …) localize by themselves; every other UI string goes through `L("…")` (menus, alerts, status text, `String` parameters such as `SoftButton`/`SettingsRow`). Never `L()` prompts, `debugLog` lines or anything stored (session titles, speaker ids). Dates use `dateText(_, template)`. After changing UI text run `python3 scripts/strings.py` (lists keys missing an English entry; `--write` adds them as TODO and regenerates the `zh-Hans` identity table, needed because the development region is English). English runs wider: check the panel, sidebars and segmented pickers in both languages.
## Layout
@@ -49,7 +49,7 @@ python3 scripts/site.py && python3 -m http.server -d build/site # website prev
Diagnostics (`Diagnostics.swift`, design: claude.ai/artifact/GHGzgN1sCodGfa17ZXLCa7): a "诊断" switch at the bottom left of the settings sidebar, beside the version (`diagnostics`, off by default; on in dev builds); switching it on adds a "诊断" tab below the others. It records only timings and counts, never transcript text: per heard sentence last new words → final transcript ("识别定稿") and final → translation, with Ling queue time, the provider that answered and why earlier ones fell through (`TranslateTrace`); per speak-back press release → transcript → translation → voice done; every Ling request (priority, queue, duration, outcome, tokens). Lines go to `metrics.jsonl` in the meeting folder (`type` = `sentence` / `ling`). The tab shows p50/p95, the provider split, fallback reasons, Ling rate and the last sentences as bars, and copies a plain-text report. It is separate from `debug`: the switch never enables transcript logging or the debug notification. Not done yet: the latency line under the subtitle bar and the health line in the panel.
-Debug control: dev builds always accept commands on the distributed notification `com.wquguru.cicada.debug` (release builds only with `defaults write com.wquguru.cicada debug -bool true`, which also logs transcript text). Send them with `tools/lsctl` (`start`, `stop`, `open`, `panel`, `onboarding:<step>`, `samplePlay`, `speakFile:<audio>`, `settings:<overlay|speak|records|ai|diagnostics>`, `diagnostics:<on|off>`, `diagReport`, `micTest`, `micNext`, `talkKey:<right|keyCode:mods>`, `toggleKey:<keyCode:mods>`, `shortcuts`, `aiKeyFile:<path>` (key from a 0600 file, never through the log), `aiCheck`, `aiRemove`, `aiState`, `lingSimulate:<429|hijack|timeout|off>`, `voice:<lang>[=<id>]`, `voicePreview:<lang>=<id>`, `voiceCloneFile:<wav>`, `display:<notes|bar|none>`, `subtitles:<both|translation|original>`, `meetingSubtitles:<…>`, `notesLang:<mine|source>`, `meetingNotesLang:<…>`, `notesRegenerate:<id>=<mine|source>`, `settings:language`, `notesWindow[:x,y,w,h]`, `notesFrame`, `notesNow`, `notesState`, `notesShow:<id>`, `notesReplay:<id>`, `notesRender:<png>`, `notesCapturable`, `mainShow:<id>[,transcript]`, `mainRender:<png>` (the main window, plus the shown meeting's whole notes page as `<png>.notes.png`), `place:x,y,w,font`, `frame`, `overlayState`, `export:<dir>` …).
+Debug control: dev builds always accept commands on the distributed notification `com.wquguru.cicada.debug` (release builds only with `defaults write com.wquguru.cicada debug -bool true`, which also logs transcript text). Send them with `tools/lsctl` (`start`, `stop`, `open`, `panel`, `onboarding:<step>`, `samplePlay`, `speakFile:<audio>`, `settings:<overlay|speak|records|ai|diagnostics>`, `diagnostics:<on|off>`, `diagReport`, `micTest`, `micNext`, `talkKey:<right|keyCode:mods>`, `toggleKey:<keyCode:mods>`, `shortcuts`, `aiKeyFile:<path>` (key from a 0600 file, never through the log), `aiCheck`, `aiRemove`, `aiState`, `lingSimulate:<429|hijack|timeout|off>`, `voice:<lang>[=<id>]`, `voicePreview:<lang>=<id>`, `voiceCloneFile:<wav>`, `display:<notes|bar|none>`, `subtitles:<both|translation|original>`, `meetingSubtitles:<…>`, `notesLang:<mine|source>`, `meetingNotesLang:<…>`, `notesRegenerate:<id>=<mine|source>`, `settings:language`, `notesWindow[:x,y,w,h]`, `notesClose` (its close button), `notesFrame`, `notesNow`, `notesState`, `notesShow:<id>`, `notesReplay:<id>`, `notesRender:<png>`, `notesCapturable`, `windowsRender:<dir>` (every visible window as drawn), `settingsRender:<section>=<png>` (one settings page in full), `mainShow:<id>[,transcript]`, `mainRender:<png>` (the main window, plus the shown meeting's whole notes page as `<png>.notes.png`), `place:x,y,w,font`, `frame`, `overlayState`, `export:<dir>` …).
Release: `scripts/release.sh <x.y.z>` (clean `main`, a `## x.y.z — <today>` section in `CHANGELOG.md`) bumps `Resources/Info.plist`, commits, tags `v<x.y.z>` and pushes; `.github/workflows/release.yml` (runner `macos-26`) builds the tag, checks it matches Info.plist and publishes the DMG, zip and checksums with notes from `scripts/release_notes.sh`. `build.yml` runs on pull requests and on demand only: macOS minutes are expensive for a private repo.
@@ -57,7 +57,7 @@ Only Command Line Tools are required (no Xcode project). Do not add an `.xcodepr
## Verifying changes
-Run the app and check the behaviour, not just the build. The pattern used so far: dev build, `tools/lsctl` to drive it, `afplay Resources/sample/sample.m4a` (or `say -o` clips) as the "someone talking" input, read `/tmp/livesubs-dev-debug.log`, screenshot windows with `screencapture -l <id>` (`tools/winall`). Synthetic mouse/key events (`tools/mouse`, `tools/key`, `tools/toggle-key`) need the terminal to have Accessibility access. The notes window is excluded from screen capture: send `notesCapturable` before `screencapture -l`, or `notesRender:<png>` for the whole notes column. Ling tests need a key: `aiKeyFile:` a 0600 file in the scratchpad, deleted right after. Synthetic keys reach every app: another app's launcher may take ⌥ Space. The real microphone, the BlackHole install (password), granting Input Monitoring and a Mac without permissions need a person.
+Run the app and check the behaviour, not just the build. For the English UI: `defaults write com.wquguru.cicada.dev AppleLanguages -array en`, relaunch, and `defaults delete com.wquguru.cicada.dev AppleLanguages` afterwards. The pattern used so far: dev build, `tools/lsctl` to drive it, `afplay Resources/sample/sample.m4a` (or `say -o` clips) as the "someone talking" input, read `/tmp/livesubs-dev-debug.log`, screenshot windows with `screencapture -l <id>` (`tools/winall`). Synthetic mouse/key events (`tools/mouse`, `tools/key`, `tools/toggle-key`) need the terminal to have Accessibility access. The notes window is excluded from screen capture: send `notesCapturable` before `screencapture -l`, or `notesRender:<png>` for the whole notes column. Ling tests need a key: `aiKeyFile:` a 0600 file in the scratchpad, deleted right after. Synthetic keys reach every app: another app's launcher may take ⌥ Space. The real microphone, the BlackHole install (password), granting Input Monitoring and a Mac without permissions need a person.
TODO: unit tests for the pure parts (language-code mapping, detection scoring, SRT/Markdown export). Swift Testing under Command Line Tools needs extra framework search paths (see cameo's `scripts/test.sh`).
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6dd9f49..3da709f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,15 @@ the release workflow publishes it as the release notes.
## Unreleased
+- Fixed: with the heard language on 自动识别, the first sentences of a meeting (everything said before the language was confirmed, usually the first 2–5 s) were shown but never saved to the meeting record or the notes. They are now recorded, with their translation and the time they were said, as soon as the language is confirmed.
+- Fixed: if the app was force-quit or crashed during a meeting, its recording (`system.m4a`, `mic.m4a`) could not be opened. Meetings are now recorded in a format that survives that, and turned into .m4a when the meeting ends or, after a crash, the next time the app starts.
+- Fixed: changing the notes language while the notes were being updated kept the notes in the old language. The rewrite now runs right after, and the reply in the old language is dropped.
+- Fixed: a point mentioned again later in a meeting moved its time to the later mention; it now keeps the time it was first said.
+- Fixed: entering a key that Ling refuses left the notes window asking for a key, with no sign it was wrong; it now says the key is invalid.
+- Fixed: recording the shortcut that is already set (or 恢复默认 when it is the default) was refused as "taken by another app".
+- Fixed: the English interface cut off the route line in Settings › Language, the "Follow system" badge and the interpreting line in the menu bar panel, the status line in the notes window, the collapsed card's "New since collapsed" and the own-voice card.
+- Fixed: 诊断 kept counting the meeting's minutes after it ended, and 新手引导 asked for system audio permission again whenever listening was paused.
+- New: the app speaks English. Menus, settings, the panel, the notes and main windows, onboarding, alerts, exports and the permission prompts follow the macOS language: Chinese on Chinese systems (Traditional too), English elsewhere. The notes themselves still follow the notes language.
- New: meetings name themselves. The notes give each meeting a short name in the notes language, and the records list, the page title and exports show the date and that name ("11月1日 Lumen 发布与结账转化问题讨论") instead of "会议 11月1日 20:16". A title you typed is kept; 恢复自动标题 in the list's right-click menu brings the automatic one back.
- New: Settings › 语言 puts every language choice in one place, under a line that reads the whole route ("对方说 English → 字幕 简体中文 · 纪要 简体中文 / 你说 中文 → 对方听到 English"): what the other side speaks, what the subtitles show (原文 + 译文 / 只看译文 / 只看原文 — the last translates nothing and uses no Ling quota; also in the menu bar panel), what to translate into, the notes language (你的语言 or the meeting's own), and the speak-back pair. 显示 and 同声传译 no longer hold these.
- New: an "EN → 中" chip in the live notes window changes the subtitles and notes language for this meeting only; a new notes language rewrites the notes right away. After a meeting, "改用 English 重新整理" writes its notes again in the other language.
diff --git a/README.md b/README.md
index e2a6c09..9e2731e 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ Cicada (知了, formerly Live Subs) is a macOS menu bar app that listens to what
### Live subtitles and language detection
- **Detects the language within half a second.** Every installed on-device speech model listens to the same audio at once, and the most confident one wins. Speech recognition runs on your Mac via Apple SpeechAnalyzer.
-- **Translates into your language.** Follows your system languages by default (if the speaker is already using your primary language, Cicada translates into your next system language), or lets you pick a target language manually. Settings › 语言 shows the whole route in one line and lets subtitles show both lines, only the translation, or only the original (nothing is translated). An `EN → 中` chip in the notes window changes the languages for one meeting.
+- **Translates into your language.** Follows your system languages by default (if the speaker is already using your primary language, Cicada translates into your next system language), or lets you pick a target language manually. Settings › Language shows the whole route in one line and lets subtitles show both lines, only the translation, or only the original (nothing is translated). A language chip in the notes window (`EN → 中`, or `EN → ZH` in the English UI) changes the languages for one meeting.
- **A subtitle bar that stays out of the way.** Press `⌃⌥S` to cycle between the notes window, the classic subtitle bar, and hidden. The bar appears only when someone speaks, shrinks to a dot when it is quiet, and turns see-through under your pointer so you can click right through it. Rest the pointer on it for 0.6 seconds to drag or resize, or double-click to reset. Each display remembers its own position and size.
### Speak back in their language
@@ -55,7 +55,7 @@ Cicada (知了, formerly Live Subs) is a macOS menu bar app that listens to what
### Meeting records
- **Saved on your Mac.** Every session gets its own folder with the bilingual transcript, notes and audio recording. Speakers are labeled as you and the other side (individual remote speakers are not separated yet).
-- **Export anywhere.** Export to Markdown or Word (both start with the meeting notes) or SRT subtitles. If you recorded a meeting without live notes, click **生成纪要** afterward to generate them.
+- **Export anywhere.** Export to Markdown or Word (both start with the meeting notes) or SRT subtitles. If you recorded a meeting without live notes, click **Generate Notes** afterward to generate them.
<p align="center">
<img src="docs/panel.png" width="300" alt="The menu bar panel">
@@ -83,10 +83,12 @@ On first launch, a three-step guide helps you grant system audio capture permiss
## Usage
+The app is in English or Chinese, following your macOS language (Settings › General › Language & Region, or per app).
+
1. Play any video, livestream or call. The live notes window opens by default, and pressing `⌃⌥S` switches between the notes window, the subtitle bar and hidden.
2. Click the Cicada icon in the menu bar to change the spoken language (auto by default), the target translation language, or the display mode.
3. To use live notes, paste your [Ling API key](https://chat.ant-ling.com/open) in **Settings › AI 服务** or in the notes window prompt.
-4. To speak back in another language, turn on **同声传译** in the menu bar panel, set your meeting app's microphone to **BlackHole 2ch**, and hold the right `⌥` key while speaking (macOS will ask for Input Monitoring permission the first time).
+4. To speak back in another language, turn on **Interpreting** in the menu bar panel, set your meeting app's microphone to **BlackHole 2ch**, and hold the right `⌥` key while speaking (macOS will ask for Input Monitoring permission the first time).
5. Open **会议记录** from the menu bar panel to search past transcripts (`⌘F`), generate notes for older sessions, or export to Markdown, Word or SRT.
## Uninstall
diff --git a/README.zh-CN.md b/README.zh-CN.md
index f5981a1..14bb3d4 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -83,6 +83,8 @@
## 使用方法
+界面有中文和英文两种,跟随 macOS 的系统语言(也可以在“系统设置 › 通用 › 语言与地区”里单独给知了指定)。
+
1. 放任何有声音的视频、直播或会议,默认会弹出实时纪要窗口。随时按 `⌃⌥S` 可以在实时纪要窗口、字幕条和不显示之间切换(快捷键可在设置里改)。
2. 点菜单栏上的知了图标,可以调整听到的语言(默认自动识别)、翻译成的语言以及显示方式。
3. 想用实时纪要的话,去 [Ling 开放平台](https://chat.ant-ling.com/open) 申请一个 API key,填进“设置 › AI 服务”或纪要窗口的提示框里。
diff --git a/Resources/Info.plist b/Resources/Info.plist
index d6c6a08..2bdf995 100644
--- a/Resources/Info.plist
+++ b/Resources/Info.plist
@@ -3,10 +3,11 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
- <string>zh_CN</string>
+ <string>en</string>
<key>CFBundleLocalizations</key>
<array>
<string>zh-Hans</string>
+ <string>zh-Hant</string>
<string>en</string>
</array>
<key>LSHasLocalizedDisplayName</key>
@@ -40,10 +41,10 @@
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2026 知了 Cicada</string>
<key>NSAudioCaptureUsageDescription</key>
- <string>知了需要读取系统正在播放的声音,用于生成实时字幕。</string>
+ <string>Cicada reads the sound your Mac is playing to make live subtitles.</string>
<key>NSMicrophoneUsageDescription</key>
- <string>按住快捷键说话时,知了需要麦克风把你的话翻译成对方的语言。</string>
+ <string>While you hold the talk key, Cicada uses the microphone to translate what you say into the other side's language.</string>
<key>NSSpeechRecognitionUsageDescription</key>
- <string>知了需要语音识别权限,把音频转成文字。</string>
+ <string>Cicada uses speech recognition to turn audio into text.</string>
</dict>
</plist>
diff --git a/Resources/en.lproj/InfoPlist.strings b/Resources/en.lproj/InfoPlist.strings
index 803669b..f50ae2c 100644
--- a/Resources/en.lproj/InfoPlist.strings
+++ b/Resources/en.lproj/InfoPlist.strings
@@ -1,2 +1,5 @@
CFBundleName = "Cicada";
CFBundleDisplayName = "Cicada";
+NSAudioCaptureUsageDescription = "Cicada reads the sound your Mac is playing to make live subtitles.";
+NSMicrophoneUsageDescription = "While you hold the talk key, Cicada uses the microphone to translate what you say into the other side's language.";
+NSSpeechRecognitionUsageDescription = "Cicada uses speech recognition to turn audio into text.";
diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings
new file mode 100644
index 0000000..ca5ec06
--- /dev/null
+++ b/Resources/en.lproj/Localizable.strings
@@ -0,0 +1,551 @@
+/* AISettings */
+"用在哪里" = "Where it's used";
+"一小时会议约 ¥0.15–1(目前优惠价)。发出去的只有文字(用你自己的声音时还有那段录音),语音识别留在本机。" = "About ¥0.15–1 per hour of meeting (current discount pricing). Only text is sent (plus your voice sample if you use your own voice); speech recognition stays on this Mac.";
+"实时纪要" = "Live notes";
+"用 Ling" = "Ling";
+"需要 key" = "Needs key";
+"会中每 45 秒更新" = "Updated every 45 s during a meeting";
+"填好 key 后可用" = "Available once a key is set";
+"翻译" = "Translation";
+"整句用 Ling;不行时换 Google、本机" = "Full sentences use Ling; falls back to Google, then on-device";
+"没有 key 时照常可用" = "Works without a key";
+"语音识别" = "Speech recognition";
+"本机" = "On-device";
+"更快,不花钱" = "Faster, and free";
+"同声传译的声音" = "Interpreting voice";
+"Ming 的声音或你自己的声音" = "A Ming voice or your own voice";
+"没有 key 时用本机声音" = "Uses the Mac's voice without a key";
+"去选声音" = "Choose voice";
+"模型" = "Model";
+"3.1 更准;3.0 更快、更省" = "3.1 is more accurate; 3.0 is faster and cheaper";
+"在 Ling 开放平台点“创建令牌”,复制以 sk- 开头的那串。" = "On the Ling platform, click “Create token” and copy the string that starts with sk-.";
+"打开 Ling 开放平台 ↗" = "Open the Ling platform ↗";
+"还没填 API key" = "No API key yet";
+"正在检查…" = "Checking…";
+"已连接" = "Connected";
+"这个 key 用不了" = "This key doesn't work";
+"暂时连不上" = "Can't connect right now";
+"%@ · 响应约 %@ 秒" = "%1$@ · responds in about %2$@ s";
+"Ling 提示此令牌无效,请检查是否复制完整,或重新创建一个" = "Ling says this token is invalid. Check that you copied all of it, or create a new one";
+"不填 key 时,字幕和翻译仍可正常使用" = "Subtitles and translation work without a key";
+"更换" = "Change";
+"重试" = "Retry";
+"保存并检查" = "Save and check";
+"取消" = "Cancel";
+"只存在这台 Mac 上(只有你的账户能读),只发给 Ling(ant-ling.com)" = "Stored only on this Mac, sent only to Ling (ant-ling.com)";
+"移除" = "Remove";
+
+/* AppMenu */
+"关于 %@" = "About %@";
+"设置…" = "Settings…";
+"AI 服务…" = "AI Service…";
+"隐藏 %@" = "Hide %@";
+"隐藏其他" = "Hide Others";
+"全部显示" = "Show All";
+"退出 %@" = "Quit %@";
+"纪要" = "Notes";
+"停止记录" = "Stop Recording";
+"立即更新纪要" = "Update Notes Now";
+"收起后的新内容" = "New Since Collapsed";
+"复制纪要" = "Copy Notes";
+"导出" = "Export";
+"SRT 字幕…" = "SRT Subtitles…";
+"会议记录" = "Meetings";
+"显示" = "Display";
+"字幕条" = "Subtitle bar";
+"不显示" = "None";
+"小卡" = "Card";
+"侧栏" = "Sidebar";
+"纪要和原话并排" = "Notes and Transcript Side by Side";
+"始终置顶" = "Always on Top";
+"编辑" = "Edit";
+"撤销" = "Undo";
+"重做" = "Redo";
+"剪切" = "Cut";
+"拷贝" = "Copy";
+"粘贴" = "Paste";
+"全选" = "Select All";
+"搜索文字记录" = "Search Transcript";
+"窗口" = "Window";
+"最小化" = "Minimize";
+"关闭" = "Close";
+"帮助" = "Help";
+"新手引导" = "Getting Started";
+"开始记录" = "Start Recording";
+
+/* AppModel */
+"准备就绪" = "Ready";
+"你正在说…" = "You're speaking…";
+"你:%@" = "You: %@";
+"结束这场会议?" = "End this meeting?";
+"已记录 %@ · %lld 句。结束后停止收听,并整理一份完整版纪要。" = "Recorded %@ · %lld lines. Ending stops listening and writes the full notes.";
+"结束会议" = "End Meeting";
+"继续记录" = "Keep Recording";
+"右 ⌥ 只能用于“按住说话”" = "Right ⌥ can only be used for “Hold to talk”";
+"与另一个快捷键冲突" = "Conflicts with the other shortcut";
+"%@ 是系统快捷键,换一个吧" = "%@ is a system shortcut; choose another";
+"%@ 已被其他应用占用,换一个吧" = "%@ is taken by another app; choose another";
+"欢迎使用%@" = "Welcome to %@";
+"设置" = "Settings";
+"正在记录会议" = "A meeting is being recorded";
+"退出会结束这场记录,已记下的内容会保存。" = "Quitting ends this recording. What has been recorded so far is saved.";
+"退出" = "Quit";
+
+/* Diagnostics */
+"%@ %@ 诊断 %@" = "%1$@ %2$@ diagnostics %3$@";
+"模型 %@" = "Model %@";
+"本场 %.0f 分钟" = "This meeting %.0f min";
+"说完到出字幕 " = "Speech end → subtitle ";
+"识别定稿 " = "Final transcript ";
+"翻译 " = "Translation ";
+"同声传译(松开到译好)" = "Interpreting (release → translated) ";
+"单轮纪要耗时 " = "Notes round ";
+"翻译来源 " = "Translated by ";
+"换后备 " = "Fallbacks ";
+"无" = "none";
+"Ling 请求 %d 次 · 排队最久 %.2fs · token %d/%d" = "Ling requests: %d · longest queue %.2fs · tokens %d/%d";
+"这场会议 · %lld 分钟 · %lld 句 · 同声传译 %lld 次" = "This meeting · %lld min · sentences: %lld · interpreted: %lld";
+"开始聆听后,这里会显示每句话的耗时明细" = "Once listening starts, the timing of every sentence shows here";
+"说完到上屏" = "Speech end → on screen";
+"识别定稿" = "Final transcript";
+"纪要一轮" = "Notes round";
+"只记时间和次数,不存字幕原文" = "Only timings and counts are recorded, never the words";
+"已复制" = "Copied";
+"复制诊断信息" = "Copy Diagnostics";
+"打开日志" = "Open Log";
+"打开本场数据" = "Open Meeting Data";
+"暂无数据" = "No data yet";
+"Ming 语音" = "Ming voice";
+"没译出" = "Not translated";
+"被搜索劫持" = "Search hijack";
+"限流" = "Rate limited";
+"超时" = "Timeout";
+"回复格式不对" = "Bad reply format";
+"网络错误" = "Network error";
+"未安装语言包" = "Language not installed";
+"翻译通道分布" = "Translation providers";
+"共 %lld 句" = "Total: %lld";
+"Ling 请求速度" = "Ling request rate";
+"账号上限约每秒 2 次" = "The account allows about 2 per second";
+"排队最久" = "Longest queue";
+"本场用量" = "This meeting's usage";
+"%.1f / 2 次每秒" = "%.1f / 2 per second";
+"%lld 次 · %lld token" = "requests: %lld · tokens: %lld";
+"最近的句子" = "Recent sentences";
+"还没有" = "None yet";
+"你" = "You";
+"对方" = "Them";
+"%@ · %lld 字" = "%@ · chars: %lld";
+
+/* LanguageSettings */
+"听对方" = "Listening";
+"同声传译" = "Interpreting";
+"对方说的语言" = "Language they speak";
+"字幕" = "Subtitles";
+"只看原文时不翻译,也不用 Ling 额度" = "Original: no translation, no Ling quota";
+"翻译成" = "Translate to";
+"只按这种语言识别" = "Recognize only this language";
+"自动识别" = "Auto-detect";
+"对方说的正是系统语言时,翻成系统里的另一种" = "When they speak your system language, translates into your other system language";
+"对方说的就是这种语言时不翻译" = "Not translated when they already speak this language";
+"跟随系统(%@)" = "Follow system (%@)";
+"跟随系统" = "Follow system";
+"纪要语言" = "Notes language";
+"实时纪要和完整版同一种语言" = "Live and full notes use the same language";
+"我的语言 · %@" = "Mine · %@";
+"我说" = "I speak";
+"同声传译还没打开" = "Interpreting is off";
+"对方听到" = "They hear";
+"跟随对方时,对方说什么语言就翻成什么" = "Following them: translated into whatever language they speak";
+"跟随对方(%@)" = "Follow them (%@)";
+"跟随对方" = "Follow them";
+"对方说" = "They say";
+"原文" = "Original";
+"(同声传译未开)" = "(interpreting off)";
+"你说" = "You say";
+"现在听出是 %@" = "Currently hearing %@";
+"从已安装的语音模型里挑最有把握的" = "Picks the most confident of the installed speech models";
+"会议原文 · %@" = "Meeting's own · %@";
+"会议原文" = "Meeting's own";
+
+/* Ling */
+"连不上 Ling,检查网络或代理" = "Can't reach Ling; check your network or proxy";
+
+/* ListenEngine */
+"%@(识别中…)→ %@" = "%1$@ (detecting…) → %2$@";
+"自动识别 → %@" = "Auto-detect → %@";
+"正在听" = "Listening";
+"此 Mac 不支持本机语音识别" = "This Mac doesn't support on-device speech recognition";
+"无法读取系统音频,请在系统设置里允许“系统音频录制”" = "Can't read system audio. Allow “System Audio Recording” in System Settings";
+"已暂停" = "Paused";
+"正在下载 %@ 语音模型…" = "Downloading the %@ speech model…";
+"本机不支持%@识别" = "This Mac can't recognize %@";
+"识别出错,%lld 秒后重试" = "Recognition error; retrying in %lld s";
+"正在识别语言…" = "Detecting language…";
+"翻译暂不可用" = "Translation unavailable for now";
+
+/* NotesViews */
+"总结" = "Summary";
+"刚更新" = "Just updated";
+"完整版" = "Full version";
+"速记版 · 到 %@" = "Draft · up to %@";
+"速记版" = "Draft";
+"议题" = "Topics";
+"结论" = "Conclusions";
+"结论和待办" = "Conclusions and to-dos";
+"人名和术语" = "Names and terms";
+" · 原识别 %@" = " · heard as %@";
+"依据较少" = "Little evidence";
+"依据 %lld 句" = "Evidence: %lld";
+"%@ · %lld 句" = "%@ · %lld lines";
+"看原话" = "See what was said";
+"正在讲" = "Now";
+"新" = "New";
+"%@ 起" = "From %@";
+"回到原话" = "Back to transcript";
+"点击分支跳回原话" = "Click a branch to jump to what was said";
+"鱼骨图" = "Fishbone";
+"为什么" = "Why";
+"依据较少,仅供参考" = "Little evidence; for reference only";
+"说话的内容会出现在这里" = "What's said will appear here";
+"%lld 句新内容" = "%lld new lines";
+"正在说" = "Speaking";
+"有人说话时,会自动开始写纪要" = "Notes start on their own once someone speaks";
+"已听到 %lld 句" = "Heard %lld lines";
+"正在生成纪要" = "Writing notes";
+"正在更新" = "Updating";
+
+/* NotesWindow */
+"key 已失效(令牌被删或免费额度用尽),纪要停留在 %@。" = "The key stopped working (token deleted or free quota used up). Notes stop at %@.";
+"请求过于频繁,稍后会自动重试。纪要停留在 %@。" = "Too many requests; retrying shortly. Notes stop at %@.";
+"这轮没整理好,下一轮会自动重试。" = "This round failed; the next one will retry.";
+"结束这场会议" = "End this meeting";
+"收窄" = "Narrow";
+"收成小卡" = "Collapse to card";
+"会议纪要" = "Meeting notes";
+"正在听 · " = "Listening · ";
+"正在记录 · " = "Recording · ";
+"%lld 句" = "%lld lines";
+"纪要已更新至 %@" = "Notes up to %@";
+"刚刚更新" = "Updated just now";
+"%lld 秒前更新" = "Updated %lld s ago";
+"%lld 分钟前更新" = "Updated %lld min ago";
+"这场会议的语言" = "Languages for this meeting";
+"结束" = "End";
+"文字记录 · %lld" = "Transcript · %lld";
+"文字记录" = "Transcript";
+"在文字记录中搜索 ⌘F" = "Search transcript ⌘F";
+"无结果" = "No results";
+"上一个" = "Previous";
+"下一个" = "Next";
+"清除" = "Clear";
+"已结束 · " = "Ended · ";
+"没有在记录" = "Not recording";
+"中" = "ZH";
+"繁" = "ZH-TW";
+"日" = "JA";
+"韩" = "KO";
+"自动" = "Auto";
+"打开语言设置" = "Open language settings";
+"收起" = "Close";
+"这场会议" = "This meeting";
+"只改这一场,默认值在 设置 › 语言" = "Changes only this meeting; defaults are in Settings › Language";
+"还没听出来" = "Not detected yet";
+"双语" = "Both";
+"只看译文" = "Translation";
+"只看原文" = "Original";
+"换了以后会马上用新语言重写纪要" = "Changing it rewrites the notes in the new language right away";
+"%@(原文)" = "%@ (original)";
+"会议已结束,正在整理完整版纪要…" = "Meeting ended; writing the full notes…";
+"会议已结束,文字记录已保存" = "Meeting ended; transcript saved";
+"会议已结束,完整版纪要已整理好 · " = "Meeting ended; full notes ready · ";
+"现在没有在记录" = "Not recording";
+"改用%@重新整理" = "Rewrite in %@";
+"在会议记录中查看" = "View in Meetings";
+"开始新会议" = "New Meeting";
+"更换 key" = "Change Key";
+"生成纪要需要 API key" = "Notes need an API key";
+"文字记录仍在正常保存。填入 Ling 的 key 后,会从头开始整理整场会议的内容。" = "The transcript is still being saved. Once you add a Ling key, notes are written for the whole meeting from the start.";
+"获取 Ling key ↗" = "Get a Ling key ↗";
+"保存并开始" = "Save and Start";
+"没有进行中的会议" = "No meeting in progress";
+"这场会议还没有纪要" = "No notes for this meeting yet";
+"这 %@ 讲了" = "In these %@";
+"收起 %@ · " = "Collapsed %@ · ";
+"还在讲这个" = "still on this";
+"没有新内容" = "nothing new";
+"收起之后 · %@ – %@" = "Since collapsed · %1$@ – %2$@";
+"展开纪要" = "Expand Notes";
+"正在讲 · " = "Now · ";
+"最后一个议题 · " = "Last topic · ";
+"正在记录" = "Recording";
+"%lld 秒" = "%lld s";
+"%lld 分钟" = "%lld min";
+"纪要里还没有新内容" = "Nothing new in the notes yet";
+"看过了" = "Got It";
+"还没有纪要" = "No notes yet";
+"正在生成纪要…" = "Writing notes…";
+"%lld 个议题" = "%lld topics";
+"%lld 条要点" = "%lld points";
+"收起后新增 " = "New: ";
+
+/* Onboarding */
+"先打开“听电脑里的声音”" = "Turn on “Hear the Mac's audio” first";
+"以后再说" = "Later";
+"上一步" = "Back";
+"继续" = "Continue";
+"开始使用" = "Get Started";
+"先打开两个开关" = "Turn on two switches";
+"去系统设置打开,回来会自动识别。" = "Turn them on in System Settings; this updates when you come back.";
+"声音只在本机识别" = "Audio is recognized only on this Mac";
+"听电脑里的声音" = "Hear the Mac's audio";
+"必需" = "Required";
+"用于生成字幕,不会录制屏幕画面" = "For subtitles; the screen is never recorded";
+"麦克风" = "Microphone";
+"可选" = "Optional";
+"仅在同声传译时使用" = "Used only for interpreting";
+"已打开" = "On";
+"去开启" = "Turn On";
+"已允许" = "Allowed";
+"允许" = "Allow";
+"去打开" = "Open Settings";
+"字幕条可任意拖动,拖拽右下角可调整大小。" = "Drag the subtitle bar anywhere; drag its corner to resize.";
+"放一段视频试试" = "Try a video";
+"点击播放,看看实时字幕效果。" = "Press play to see live subtitles.";
+"播放示例视频" = "Play sample video";
+"示例 · 0:07" = "Sample · 0:07";
+"正在听…" = "Listening…";
+"听到" = "Hearing";
+"自动 · %@" = "Auto · %@";
+"最后一步:在会议软件中,将麦克风选为 " = "Last step: in your meeting app, set the microphone to ";
+"想让对方听懂你?" = "Want them to understand you?";
+"按住说%@,对方听到翻译后的语音。" = "Hold and speak %@; they hear it translated.";
+"可在设置中更改" = "Change it in Settings";
+"右侧 option" = "Right option";
+"按住说话" = "Hold to talk";
+
+/* Overlay */
+"你在说… " = "You're speaking… ";
+"翻译中… " = "Translating… ";
+"你:" = "You: ";
+
+/* SessionStore */
+"会议 %@" = "Meeting %@";
+"不到 1 分钟" = "Under 1 min";
+"待办" = "To-dos";
+
+/* SettingsWindow */
+"语言" = "Language";
+"AI 服务" = "AI Service";
+"诊断" = "Diagnostics";
+"原文 + 译文" = "Both";
+"恢复默认(%@)" = "Reset (%@)";
+"按 esc 取消" = "Press esc to cancel";
+"点击更换按键" = "Click to change";
+"按下组合键,或单按右 ⌥" = "Press a combination, or right ⌥ alone";
+"按下新的组合键" = "Press a new combination";
+"还差一步:允许“输入监控”" = "One more step: allow “Input Monitoring”";
+"“按住右 ⌥ 说话”需要此权限。请在系统设置中勾选 %@,返回此处即可生效" = "“Hold right ⌥ to talk” needs this. Turn on %@ in System Settings, then come back";
+"去允许" = "Allow";
+"知了" = "Cicada";
+"再试一次" = "Try Again";
+"虚拟麦克风已就绪" = "Virtual microphone ready";
+"%@ · 试音通过,对方听得到" = "%@ · sound test passed, they can hear you";
+"安装" = "Install";
+"输一次电脑密码" = "Enter your Mac password once";
+"正在下载…" = "Downloading…";
+"正在安装…" = "Installing…";
+"让系统认出它" = "Load it";
+"声音会短暂中断约 1 秒" = "Audio cuts out for about 1 s";
+"正在让系统认出它…" = "Loading…";
+"试音" = "Sound Test";
+"自动播一句,确认对方听得到" = "Plays a phrase to check they can hear it";
+"正在试音…" = "Testing…";
+"虚拟麦克风" = "Virtual microphone";
+"进行中" = "In progress";
+"没装" = "Not installed";
+"系统还没认出" = "Not loaded yet";
+"还没试音" = "Not tested yet";
+"没听到声音" = "No sound heard";
+"一键安装" = "Install";
+"对方会听到:" = "They will hear: ";
+"一段声音" = "a sound";
+"虚拟麦克风未收到声音,请再试一次" = "The virtual microphone got no sound; try again";
+"按住说话,松开后约 2 秒,对方听到译文" = "Hold to talk; about 2 s after you let go, they hear the translation";
+"在会议软件中,将麦克风选为「%@」。" = "In your meeting app, set the microphone to “%@”.";
+"把我的话翻译给对方听" = "Translate what I say for them";
+"单独按住右侧 ⌥;与其他键同时按不会触发" = "Hold right ⌥ alone; it doesn't trigger with other keys";
+"说%@,对方听到%@" = "Speak %1$@, they hear %2$@";
+"声音输出到" = "Send voice to";
+"把我说的翻译给对方" = "Translate what I say for them";
+"修改" = "Change";
+"虚拟麦克风(自动)" = "Virtual microphone (auto)";
+"听的时候显示" = "While listening, show";
+"选择任意模式都会正常保存记录、生成纪要" = "Every mode still saves the meeting and writes notes";
+"切换显示方式" = "Switch display";
+"被其他应用占用了,点右边换一个" = "Taken by another app; click to change";
+"实时纪要 → 字幕条 → 不显示" = "Live notes → Subtitle bar → None";
+"显示方式" = "Display";
+"字幕条显示时机" = "Show subtitle bar";
+"安静多久后收起" = "Tuck away after quiet for";
+"位置和大小" = "Position and size";
+"鼠标悬停可拖动位置,拖拽右下角可缩放大小" = "Hover to drag it; drag the bottom-right corner to resize";
+"有人说话时" = "While someone talks";
+"始终显示" = "Always";
+"2 秒" = "2 s";
+"4 秒" = "4 s";
+"8 秒" = "8 s";
+"恢复默认" = "Reset";
+"保存会议录音" = "Save meeting audio";
+"只存在这台 Mac 上" = "Stored only on this Mac";
+"记录文件夹" = "Records folder";
+"首次引导" = "Getting started";
+"打开" = "Open";
+"重新看" = "Show Again";
+
+/* Shortcuts */
+"右 ⌥" = "Right ⌥";
+"请包含 ⌃ 或 ⌘,否则会影响正常打字" = "Include ⌃ or ⌘, or it would get in the way of typing";
+
+/* SpeakEngine */
+"无法准备语音识别:%@" = "Can't prepare speech recognition: %@";
+"语音识别仍在准备中,请再按一次" = "Speech recognition is still getting ready; press again";
+"没有可用的麦克风" = "No microphone available";
+"麦克风无法启动,请在系统设置里允许%@使用麦克风" = "The microphone won't start. Allow %@ to use it in System Settings";
+"翻译失败,这句话未发送" = "Translation failed; this sentence wasn't sent";
+
+/* SystemAudioTap */
+"无法启动音频采集(%d)" = "Can't start audio capture (%d)";
+"无法初始化音频单元(%d)" = "Can't initialize the audio unit (%d)";
+"无法设置音频回调(%d)" = "Can't set the audio callback (%d)";
+"无法设置音频格式(%d)" = "Can't set the audio format (%d)";
+"无法创建音频格式" = "Can't create the audio format";
+"无法连接音频聚合设备(%d)" = "Can't connect the aggregate audio device (%d)";
+"无法创建音频单元(%d)" = "Can't create the audio unit (%d)";
+"找不到 HAL 音频组件" = "Can't find the HAL audio component";
+"无法创建音频聚合设备(%d)" = "Can't create the aggregate audio device (%d)";
+"找不到默认输出设备" = "Can't find the default output device";
+"无法创建系统音频 Tap(%d)" = "Can't create the system audio tap (%d)";
+
+/* Views */
+"自动识别(%@)" = "Auto-detect (%@)";
+"%@(需下载)" = "%@ (download needed)";
+"系统" = "System";
+"仅本场" = "This meeting";
+"按住" = "Hold";
+"说%@ → %@" = "%1$@ → %2$@";
+"虚拟麦克风尚未设置好,对方听不到你的声音" = "The virtual microphone isn't set up; they can't hear you";
+"纪要、文字记录和字幕都在一个窗口里" = "Notes and transcript in one window";
+"填入 API key 后可生成纪要;文字记录照常保存" = "Add an API key for notes; the transcript is saved either way";
+"有人说话时显示" = "Show while someone talks";
+"收起前等待" = "Wait before tucking away";
+"搜索标题和原话" = "Search titles and transcripts";
+"开启字幕后,每场会议都会自动保存在这里。" = "Once subtitles are on, every meeting is saved here.";
+"没有找到“%@”" = "Nothing found for “%@”";
+"今天" = "Today";
+"昨天" = "Yesterday";
+"本周" = "This Week";
+"正在记录 · %@ 起 · %lld 句" = "Recording · since %@ · %lld lines";
+"在 Finder 中显示" = "Show in Finder";
+"恢复自动标题" = "Restore Automatic Title";
+"删除" = "Delete";
+"%lld 小时" = "%lld h";
+"%lld 小时 %lld 分" = "%lld h %lld min";
+"英语" = "English";
+"日语" = "Japanese";
+"中文" = "Chinese";
+"繁中" = "Trad. Chinese";
+"韩语" = "Korean";
+"西语" = "Spanish";
+"法语" = "French";
+"德语" = "German";
+"葡语" = "Portuguese";
+"打开开关开始听" = "Turn on to start listening";
+"正在听,说话的内容会出现在这里" = "Listening; what's said will appear here";
+"这场会议没有记录到内容" = "Nothing was recorded in this meeting";
+"还没有会议记录" = "No meetings yet";
+"开启字幕后,每场会议都会自动保存一份双语记录。" = "Once subtitles are on, every meeting is saved as a bilingual record.";
+"译文" = "Translation";
+"复制为 Markdown" = "Copy as Markdown";
+"导出 Markdown…" = "Export Markdown…";
+"导出 Word…" = "Export Word…";
+"导出字幕 SRT…" = "Export SRT Subtitles…";
+"标题" = "Title";
+"完整版纪要" = "Full notes";
+"速记版纪要" = "Draft notes";
+"翻译中…" = "Translating…";
+"正在整理纪要…" = "Writing notes…";
+"纪要会在会议进行中自动生成" = "Notes are written during the meeting";
+"使用 Ling 将文字记录整理为总结、议题、结论和人名,约需半分钟。" = "Ling turns the transcript into a summary, topics, conclusions and names. Takes about half a minute.";
+"前往 设置 › AI 服务 填入 Ling 的 API key 后即可生成。" = "Add a Ling API key in Settings › AI Service to generate them.";
+"正在生成…" = "Generating…";
+"生成纪要" = "Generate Notes";
+"去填 key" = "Add Key";
+
+/* VirtualMic */
+"%@要安装虚拟麦克风,让会议里的人听到你的翻译。" = "%@ wants to install a virtual microphone so people in the meeting can hear your translation.";
+"安装包校验未通过,已中止安装" = "The package failed verification; installation stopped";
+"下载失败,请检查网络" = "Download failed; check your network";
+"安装未完成,请再试一次" = "Installation didn't finish; try again";
+"系统还没认出它,点“让系统认出它”再试一次" = "macOS hasn't loaded it yet; click “Load it” and try again";
+"%@要让系统认出虚拟麦克风,声音会断约 1 秒。" = "%@ needs to load the virtual microphone; audio will cut out for about 1 second.";
+"试音要用麦克风权限,请在系统设置里允许%@" = "The sound test needs microphone access; allow %@ in System Settings";
+"打不开虚拟麦克风,点“让系统认出它”后再试" = "Can't open the virtual microphone; click “Load it” and try again";
+
+/* VoicePicker */
+"每种语言会记住你选的声音。对方当前在说%@。" = "Each language remembers its voice. They're speaking %@ now.";
+"对方听到的声音" = "The voice they hear";
+"未填写 Ling key 时仅可使用系统声音;填入 key 后可使用 Ming 语音或克隆你自己的声音。" = "Without a Ling key only the Mac's voices are available; with one you can use Ming voices or clone your own.";
+"录音仅保存在本机,每次发言时随文字发送给 Ling 合成语音;Ling 不可用时自动切回系统声音。" = "The recording stays on this Mac and is sent to Ling with each sentence to synthesize speech; falls back to the Mac's voice when Ling is unavailable.";
+"Ming 语音需使用 Ling key,延迟约 1.5 秒;Ling 不可用时自动切回系统声音。" = "Ming voices need a Ling key and add about 1.5 s; falls back to the Mac's voice when Ling is unavailable.";
+"更多…" = "More…";
+"试听" = "Preview";
+"需要 Ling key" = "Needs Ling key";
+"用这个" = "Use";
+"重录" = "Re-record";
+"录制" = "Record";
+"我自己的声音" = "My own voice";
+"已录好 · %lld 秒 · %@" = "Recorded · %lld s · %@";
+"录制 15 秒原声,让对方听到你的音色;说外语时会保留你的口音,延迟约 3 秒" = "Record 15 s so they hear your own voice; in a foreign language it keeps your accent, about 3 s delay";
+"说%@最像你,晚约 3 秒" = "Sounds most like you in %@, about 3 s later";
+"说%@会带你的口音,晚约 3 秒" = "Keeps your accent in %@, about 3 s later";
+"录制你的声音" = "Record your voice";
+"请用平时开会的自然语气朗读以下段落,约 15 秒,在安静环境下录制效果最佳。" = "Read this passage aloud the way you talk in meetings, about 15 s. A quiet room works best.";
+"这是我自己的声音。只在我说话时用它替我翻译。" = "This is my own voice. Use it only to translate for me when I speak.";
+"读完了" = "Done";
+"开始录" = "Start";
+"再录一次" = "Record Again";
+"正在听写…" = "Transcribing…";
+"%lld–%lld 秒" = "%lld–%lld s";
+"需先在“AI 服务”中填入 Ling key,才能使用你自己的声音。" = "Add a Ling key under “AI Service” to use your own voice.";
+"听起来不像或有杂音?换个安静的地方重录一次。录音仅保存在本机,可随时删除。" = "Doesn't sound like you, or noisy? Record again somewhere quiet. The recording stays on this Mac and can be deleted anytime.";
+"录好了,先听听像不像" = "Recorded. Listen to check it sounds like you";
+"%lld 秒 · 识别出的文字会与录音一起用于学习你的音色" = "%lld s · the recognized text is used with the recording to learn your voice";
+"你的原声" = "Your recording";
+"用你的声音说%@" = "Your voice speaking %@";
+"对方会听到这个" = "They'll hear this";
+"用这个声音" = "Use This Voice";
+
+/* Voices */
+"女" = "Female";
+"美式" = "American";
+"自然对话" = "Conversational";
+"男" = "Male";
+"英式" = "British";
+"稳重" = "Steady";
+"平稳" = "Even";
+"清亮" = "Clear";
+"播报" = "Newsreader";
+"温和" = "Gentle";
+"沉稳" = "Calm";
+"温暖" = "Warm";
+"亲切" = "Friendly";
+"沉着" = "Composed";
+"清楚" = "Crisp";
+"高品质" = "Premium";
+"增强" = "Enhanced";
+"标准" = "Standard";
+"麦克风没收到声音,请检查麦克风权限" = "The microphone got no sound; check microphone permission";
+"无法打开麦克风:%@" = "Can't open the microphone: %@";
+"录音太短了,请至少朗读 %lld 秒" = "Too short; read for at least %lld seconds";
+"没听清录音内容,请换个安静的地方再录一次" = "Couldn't make out the recording; try again somewhere quiet";
diff --git a/Resources/en.lproj/Localizable.stringsdict b/Resources/en.lproj/Localizable.stringsdict
new file mode 100644
index 0000000..e5a3ce2
--- /dev/null
+++ b/Resources/en.lproj/Localizable.stringsdict
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>%@ · %lld 句</key>
+ <dict>
+ <key>NSStringLocalizedFormatKey</key>
+ <string>%1$@ · %2$#@n@</string>
+ <key>n</key>
+ <dict>
+ <key>NSStringFormatSpecTypeKey</key>
+ <string>NSStringPluralRuleType</string>
+ <key>NSStringFormatValueTypeKey</key>
+ <string>lld</string>
+ <key>one</key>
+ <string>%lld line</string>
+ <key>other</key>
+ <string>%lld lines</string>
+ </dict>
+ </dict>
+ <key>%lld 个议题</key>
+ <dict>
+ <key>NSStringLocalizedFormatKey</key>
+ <string>%#@n@</string>
+ <key>n</key>
+ <dict>
+ <key>NSStringFormatSpecTypeKey</key>
+ <string>NSStringPluralRuleType</string>
+ <key>NSStringFormatValueTypeKey</key>
+ <string>lld</string>
+ <key>one</key>
+ <string>%lld topic</string>
+ <key>other</key>
+ <string>%lld topics</string>
+ </dict>
+ </dict>
+ <key>%lld 句</key>
+ <dict>
+ <key>NSStringLocalizedFormatKey</key>
+ <string>%#@n@</string>
+ <key>n</key>
+ <dict>
+ <key>NSStringFormatSpecTypeKey</key>
+ <string>NSStringPluralRuleType</string>
+ <key>NSStringFormatValueTypeKey</key>
+ <string>lld</string>
+ <key>one</key>
+ <string>%lld line</string>
+ <key>other</key>
+ <string>%lld lines</string>
+ </dict>
+ </dict>
+ <key>%lld 句新内容</key>
+ <dict>
+ <key>NSStringLocalizedFormatKey</key>
+ <string>%#@n@</string>
+ <key>n</key>
+ <dict>
+ <key>NSStringFormatSpecTypeKey</key>
+ <string>NSStringPluralRuleType</string>
+ <key>NSStringFormatValueTypeKey</key>
+ <string>lld</string>
+ <key>one</key>
+ <string>%lld new line</string>
+ <key>other</key>
+ <string>%lld new lines</string>
+ </dict>
+ </dict>
+ <key>%lld 条要点</key>
+ <dict>
+ <key>NSStringLocalizedFormatKey</key>
+ <string>%#@n@</string>
+ <key>n</key>
+ <dict>
+ <key>NSStringFormatSpecTypeKey</key>
+ <string>NSStringPluralRuleType</string>
+ <key>NSStringFormatValueTypeKey</key>
+ <string>lld</string>
+ <key>one</key>
+ <string>%lld point</string>
+ <key>other</key>
+ <string>%lld points</string>
+ </dict>
+ </dict>
+ <key>已听到 %lld 句</key>
+ <dict>
+ <key>NSStringLocalizedFormatKey</key>
+ <string>Heard %#@n@</string>
+ <key>n</key>
+ <dict>
+ <key>NSStringFormatSpecTypeKey</key>
+ <string>NSStringPluralRuleType</string>
+ <key>NSStringFormatValueTypeKey</key>
+ <string>lld</string>
+ <key>one</key>
+ <string>%lld line</string>
+ <key>other</key>
+ <string>%lld lines</string>
+ </dict>
+ </dict>
+ <key>已记录 %@ · %lld 句。结束后停止收听,并整理一份完整版纪要。</key>
+ <dict>
+ <key>NSStringLocalizedFormatKey</key>
+ <string>Recorded %1$@ · %2$#@n@. Ending stops listening and writes the full notes.</string>
+ <key>n</key>
+ <dict>
+ <key>NSStringFormatSpecTypeKey</key>
+ <string>NSStringPluralRuleType</string>
+ <key>NSStringFormatValueTypeKey</key>
+ <string>lld</string>
+ <key>one</key>
+ <string>%lld line</string>
+ <key>other</key>
+ <string>%lld lines</string>
+ </dict>
+ </dict>
+ <key>正在记录 · %@ 起 · %lld 句</key>
+ <dict>
+ <key>NSStringLocalizedFormatKey</key>
+ <string>Recording · since %1$@ · %2$#@n@</string>
+ <key>n</key>
+ <dict>
+ <key>NSStringFormatSpecTypeKey</key>
+ <string>NSStringPluralRuleType</string>
+ <key>NSStringFormatValueTypeKey</key>
+ <string>lld</string>
+ <key>one</key>
+ <string>%lld line</string>
+ <key>other</key>
+ <string>%lld lines</string>
+ </dict>
+ </dict>
+</dict>
+</plist>
diff --git a/Resources/zh-Hans.lproj/InfoPlist.strings b/Resources/zh-Hans.lproj/InfoPlist.strings
index 191d7b6..86acca6 100644
--- a/Resources/zh-Hans.lproj/InfoPlist.strings
+++ b/Resources/zh-Hans.lproj/InfoPlist.strings
@@ -1,2 +1,5 @@
CFBundleName = "知了";
CFBundleDisplayName = "知了";
+NSAudioCaptureUsageDescription = "知了需要读取系统正在播放的声音,用于生成实时字幕。";
+NSMicrophoneUsageDescription = "按住快捷键说话时,知了需要麦克风把你的话翻译成对方的语言。";
+NSSpeechRecognitionUsageDescription = "知了需要语音识别权限,把音频转成文字。";
diff --git a/Resources/zh-Hans.lproj/Localizable.strings b/Resources/zh-Hans.lproj/Localizable.strings
new file mode 100644
index 0000000..76eafc5
--- /dev/null
+++ b/Resources/zh-Hans.lproj/Localizable.strings
@@ -0,0 +1,551 @@
+/* AISettings */
+"用在哪里" = "用在哪里";
+"一小时会议约 ¥0.15–1(目前优惠价)。发出去的只有文字(用你自己的声音时还有那段录音),语音识别留在本机。" = "一小时会议约 ¥0.15–1(目前优惠价)。发出去的只有文字(用你自己的声音时还有那段录音),语音识别留在本机。";
+"实时纪要" = "实时纪要";
+"用 Ling" = "用 Ling";
+"需要 key" = "需要 key";
+"会中每 45 秒更新" = "会中每 45 秒更新";
+"填好 key 后可用" = "填好 key 后可用";
+"翻译" = "翻译";
+"整句用 Ling;不行时换 Google、本机" = "整句用 Ling;不行时换 Google、本机";
+"没有 key 时照常可用" = "没有 key 时照常可用";
+"语音识别" = "语音识别";
+"本机" = "本机";
+"更快,不花钱" = "更快,不花钱";
+"同声传译的声音" = "同声传译的声音";
+"Ming 的声音或你自己的声音" = "Ming 的声音或你自己的声音";
+"没有 key 时用本机声音" = "没有 key 时用本机声音";
+"去选声音" = "去选声音";
+"模型" = "模型";
+"3.1 更准;3.0 更快、更省" = "3.1 更准;3.0 更快、更省";
+"在 Ling 开放平台点“创建令牌”,复制以 sk- 开头的那串。" = "在 Ling 开放平台点“创建令牌”,复制以 sk- 开头的那串。";
+"打开 Ling 开放平台 ↗" = "打开 Ling 开放平台 ↗";
+"还没填 API key" = "还没填 API key";
+"正在检查…" = "正在检查…";
+"已连接" = "已连接";
+"这个 key 用不了" = "这个 key 用不了";
+"暂时连不上" = "暂时连不上";
+"%@ · 响应约 %@ 秒" = "%@ · 响应约 %@ 秒";
+"Ling 提示此令牌无效,请检查是否复制完整,或重新创建一个" = "Ling 提示此令牌无效,请检查是否复制完整,或重新创建一个";
+"不填 key 时,字幕和翻译仍可正常使用" = "不填 key 时,字幕和翻译仍可正常使用";
+"更换" = "更换";
+"重试" = "重试";
+"保存并检查" = "保存并检查";
+"取消" = "取消";
+"只存在这台 Mac 上(只有你的账户能读),只发给 Ling(ant-ling.com)" = "只存在这台 Mac 上(只有你的账户能读),只发给 Ling(ant-ling.com)";
+"移除" = "移除";
+
+/* AppMenu */
+"关于 %@" = "关于 %@";
+"设置…" = "设置…";
+"AI 服务…" = "AI 服务…";
+"隐藏 %@" = "隐藏 %@";
+"隐藏其他" = "隐藏其他";
+"全部显示" = "全部显示";
+"退出 %@" = "退出 %@";
+"纪要" = "纪要";
+"停止记录" = "停止记录";
+"立即更新纪要" = "立即更新纪要";
+"收起后的新内容" = "收起后的新内容";
+"复制纪要" = "复制纪要";
+"导出" = "导出";
+"SRT 字幕…" = "SRT 字幕…";
+"会议记录" = "会议记录";
+"显示" = "显示";
+"字幕条" = "字幕条";
+"不显示" = "不显示";
+"小卡" = "小卡";
+"侧栏" = "侧栏";
+"纪要和原话并排" = "纪要和原话并排";
+"始终置顶" = "始终置顶";
+"编辑" = "编辑";
+"撤销" = "撤销";
+"重做" = "重做";
+"剪切" = "剪切";
+"拷贝" = "拷贝";
+"粘贴" = "粘贴";
+"全选" = "全选";
+"搜索文字记录" = "搜索文字记录";
+"窗口" = "窗口";
+"最小化" = "最小化";
+"关闭" = "关闭";
+"帮助" = "帮助";
+"新手引导" = "新手引导";
+"开始记录" = "开始记录";
+
+/* AppModel */
+"准备就绪" = "准备就绪";
+"你正在说…" = "你正在说…";
+"你:%@" = "你:%@";
+"结束这场会议?" = "结束这场会议?";
+"已记录 %@ · %lld 句。结束后停止收听,并整理一份完整版纪要。" = "已记录 %@ · %lld 句。结束后停止收听,并整理一份完整版纪要。";
+"结束会议" = "结束会议";
+"继续记录" = "继续记录";
+"右 ⌥ 只能用于“按住说话”" = "右 ⌥ 只能用于“按住说话”";
+"与另一个快捷键冲突" = "与另一个快捷键冲突";
+"%@ 是系统快捷键,换一个吧" = "%@ 是系统快捷键,换一个吧";
+"%@ 已被其他应用占用,换一个吧" = "%@ 已被其他应用占用,换一个吧";
+"欢迎使用%@" = "欢迎使用%@";
+"设置" = "设置";
+"正在记录会议" = "正在记录会议";
+"退出会结束这场记录,已记下的内容会保存。" = "退出会结束这场记录,已记下的内容会保存。";
+"退出" = "退出";
+
+/* Diagnostics */
+"%@ %@ 诊断 %@" = "%@ %@ 诊断 %@";
+"模型 %@" = "模型 %@";
+"本场 %.0f 分钟" = "本场 %.0f 分钟";
+"说完到出字幕 " = "说完到出字幕 ";
+"识别定稿 " = "识别定稿 ";
+"翻译 " = "翻译 ";
+"同声传译(松开到译好)" = "同声传译(松开到译好)";
+"单轮纪要耗时 " = "单轮纪要耗时 ";
+"翻译来源 " = "翻译来源 ";
+"换后备 " = "换后备 ";
+"无" = "无";
+"Ling 请求 %d 次 · 排队最久 %.2fs · token %d/%d" = "Ling 请求 %d 次 · 排队最久 %.2fs · token %d/%d";
+"这场会议 · %lld 分钟 · %lld 句 · 同声传译 %lld 次" = "这场会议 · %lld 分钟 · %lld 句 · 同声传译 %lld 次";
+"开始聆听后,这里会显示每句话的耗时明细" = "开始聆听后,这里会显示每句话的耗时明细";
+"说完到上屏" = "说完到上屏";
+"识别定稿" = "识别定稿";
+"纪要一轮" = "纪要一轮";
+"只记时间和次数,不存字幕原文" = "只记时间和次数,不存字幕原文";
+"已复制" = "已复制";
+"复制诊断信息" = "复制诊断信息";
+"打开日志" = "打开日志";
+"打开本场数据" = "打开本场数据";
+"暂无数据" = "暂无数据";
+"Ming 语音" = "Ming 语音";
+"没译出" = "没译出";
+"被搜索劫持" = "被搜索劫持";
+"限流" = "限流";
+"超时" = "超时";
+"回复格式不对" = "回复格式不对";
+"网络错误" = "网络错误";
+"未安装语言包" = "未安装语言包";
+"翻译通道分布" = "翻译通道分布";
+"共 %lld 句" = "共 %lld 句";
+"Ling 请求速度" = "Ling 请求速度";
+"账号上限约每秒 2 次" = "账号上限约每秒 2 次";
+"排队最久" = "排队最久";
+"本场用量" = "本场用量";
+"%.1f / 2 次每秒" = "%.1f / 2 次每秒";
+"%lld 次 · %lld token" = "%lld 次 · %lld token";
+"最近的句子" = "最近的句子";
+"还没有" = "还没有";
+"你" = "你";
+"对方" = "对方";
+"%@ · %lld 字" = "%@ · %lld 字";
+
+/* LanguageSettings */
+"听对方" = "听对方";
+"同声传译" = "同声传译";
+"对方说的语言" = "对方说的语言";
+"字幕" = "字幕";
+"只看原文时不翻译,也不用 Ling 额度" = "只看原文时不翻译,也不用 Ling 额度";
+"翻译成" = "翻译成";
+"只按这种语言识别" = "只按这种语言识别";
+"自动识别" = "自动识别";
+"对方说的正是系统语言时,翻成系统里的另一种" = "对方说的正是系统语言时,翻成系统里的另一种";
+"对方说的就是这种语言时不翻译" = "对方说的就是这种语言时不翻译";
+"跟随系统(%@)" = "跟随系统(%@)";
+"跟随系统" = "跟随系统";
+"纪要语言" = "纪要语言";
+"实时纪要和完整版同一种语言" = "实时纪要和完整版同一种语言";
+"我的语言 · %@" = "我的语言 · %@";
+"我说" = "我说";
+"同声传译还没打开" = "同声传译还没打开";
+"对方听到" = "对方听到";
+"跟随对方时,对方说什么语言就翻成什么" = "跟随对方时,对方说什么语言就翻成什么";
+"跟随对方(%@)" = "跟随对方(%@)";
+"跟随对方" = "跟随对方";
+"对方说" = "对方说";
+"原文" = "原文";
+"(同声传译未开)" = "(同声传译未开)";
+"你说" = "你说";
+"现在听出是 %@" = "现在听出是 %@";
+"从已安装的语音模型里挑最有把握的" = "从已安装的语音模型里挑最有把握的";
+"会议原文 · %@" = "会议原文 · %@";
+"会议原文" = "会议原文";
+
+/* Ling */
+"连不上 Ling,检查网络或代理" = "连不上 Ling,检查网络或代理";
+
+/* ListenEngine */
+"%@(识别中…)→ %@" = "%@(识别中…)→ %@";
+"自动识别 → %@" = "自动识别 → %@";
+"正在听" = "正在听";
+"此 Mac 不支持本机语音识别" = "此 Mac 不支持本机语音识别";
+"无法读取系统音频,请在系统设置里允许“系统音频录制”" = "无法读取系统音频,请在系统设置里允许“系统音频录制”";
+"已暂停" = "已暂停";
+"正在下载 %@ 语音模型…" = "正在下载 %@ 语音模型…";
+"本机不支持%@识别" = "本机不支持%@识别";
+"识别出错,%lld 秒后重试" = "识别出错,%lld 秒后重试";
+"正在识别语言…" = "正在识别语言…";
+"翻译暂不可用" = "翻译暂不可用";
+
+/* NotesViews */
+"总结" = "总结";
+"刚更新" = "刚更新";
+"完整版" = "完整版";
+"速记版 · 到 %@" = "速记版 · 到 %@";
+"速记版" = "速记版";
+"议题" = "议题";
+"结论" = "结论";
+"结论和待办" = "结论和待办";
+"人名和术语" = "人名和术语";
+" · 原识别 %@" = " · 原识别 %@";
+"依据较少" = "依据较少";
+"依据 %lld 句" = "依据 %lld 句";
+"%@ · %lld 句" = "%@ · %lld 句";
+"看原话" = "看原话";
+"正在讲" = "正在讲";
+"新" = "新";
+"%@ 起" = "%@ 起";
+"回到原话" = "回到原话";
+"点击分支跳回原话" = "点击分支跳回原话";
+"鱼骨图" = "鱼骨图";
+"为什么" = "为什么";
+"依据较少,仅供参考" = "依据较少,仅供参考";
+"说话的内容会出现在这里" = "说话的内容会出现在这里";
+"%lld 句新内容" = "%lld 句新内容";
+"正在说" = "正在说";
+"有人说话时,会自动开始写纪要" = "有人说话时,会自动开始写纪要";
+"已听到 %lld 句" = "已听到 %lld 句";
+"正在生成纪要" = "正在生成纪要";
+"正在更新" = "正在更新";
+
+/* NotesWindow */
+"key 已失效(令牌被删或免费额度用尽),纪要停留在 %@。" = "key 已失效(令牌被删或免费额度用尽),纪要停留在 %@。";
+"请求过于频繁,稍后会自动重试。纪要停留在 %@。" = "请求过于频繁,稍后会自动重试。纪要停留在 %@。";
+"这轮没整理好,下一轮会自动重试。" = "这轮没整理好,下一轮会自动重试。";
+"结束这场会议" = "结束这场会议";
+"收窄" = "收窄";
+"收成小卡" = "收成小卡";
+"会议纪要" = "会议纪要";
+"正在听 · " = "正在听 · ";
+"正在记录 · " = "正在记录 · ";
+"%lld 句" = "%lld 句";
+"纪要已更新至 %@" = "纪要已更新至 %@";
+"刚刚更新" = "刚刚更新";
+"%lld 秒前更新" = "%lld 秒前更新";
+"%lld 分钟前更新" = "%lld 分钟前更新";
+"这场会议的语言" = "这场会议的语言";
+"结束" = "结束";
+"文字记录 · %lld" = "文字记录 · %lld";
+"文字记录" = "文字记录";
+"在文字记录中搜索 ⌘F" = "在文字记录中搜索 ⌘F";
+"无结果" = "无结果";
+"上一个" = "上一个";
+"下一个" = "下一个";
+"清除" = "清除";
+"已结束 · " = "已结束 · ";
+"没有在记录" = "没有在记录";
+"中" = "中";
+"繁" = "繁";
+"日" = "日";
+"韩" = "韩";
+"自动" = "自动";
+"打开语言设置" = "打开语言设置";
+"收起" = "收起";
+"这场会议" = "这场会议";
+"只改这一场,默认值在 设置 › 语言" = "只改这一场,默认值在 设置 › 语言";
+"还没听出来" = "还没听出来";
+"双语" = "双语";
+"只看译文" = "只看译文";
+"只看原文" = "只看原文";
+"换了以后会马上用新语言重写纪要" = "换了以后会马上用新语言重写纪要";
+"%@(原文)" = "%@(原文)";
+"会议已结束,正在整理完整版纪要…" = "会议已结束,正在整理完整版纪要…";
+"会议已结束,文字记录已保存" = "会议已结束,文字记录已保存";
+"会议已结束,完整版纪要已整理好 · " = "会议已结束,完整版纪要已整理好 · ";
+"现在没有在记录" = "现在没有在记录";
+"改用%@重新整理" = "改用%@重新整理";
+"在会议记录中查看" = "在会议记录中查看";
+"开始新会议" = "开始新会议";
+"更换 key" = "更换 key";
+"生成纪要需要 API key" = "生成纪要需要 API key";
+"文字记录仍在正常保存。填入 Ling 的 key 后,会从头开始整理整场会议的内容。" = "文字记录仍在正常保存。填入 Ling 的 key 后,会从头开始整理整场会议的内容。";
+"获取 Ling key ↗" = "获取 Ling key ↗";
+"保存并开始" = "保存并开始";
+"没有进行中的会议" = "没有进行中的会议";
+"这场会议还没有纪要" = "这场会议还没有纪要";
+"这 %@ 讲了" = "这 %@ 讲了";
+"收起 %@ · " = "收起 %@ · ";
+"还在讲这个" = "还在讲这个";
+"没有新内容" = "没有新内容";
+"收起之后 · %@ – %@" = "收起之后 · %@ – %@";
+"展开纪要" = "展开纪要";
+"正在讲 · " = "正在讲 · ";
+"最后一个议题 · " = "最后一个议题 · ";
+"正在记录" = "正在记录";
+"%lld 秒" = "%lld 秒";
+"%lld 分钟" = "%lld 分钟";
+"纪要里还没有新内容" = "纪要里还没有新内容";
+"看过了" = "看过了";
+"还没有纪要" = "还没有纪要";
+"正在生成纪要…" = "正在生成纪要…";
+"%lld 个议题" = "%lld 个议题";
+"%lld 条要点" = "%lld 条要点";
+"收起后新增 " = "收起后新增 ";
+
+/* Onboarding */
+"先打开“听电脑里的声音”" = "先打开“听电脑里的声音”";
+"以后再说" = "以后再说";
+"上一步" = "上一步";
+"继续" = "继续";
+"开始使用" = "开始使用";
+"先打开两个开关" = "先打开两个开关";
+"去系统设置打开,回来会自动识别。" = "去系统设置打开,回来会自动识别。";
+"声音只在本机识别" = "声音只在本机识别";
+"听电脑里的声音" = "听电脑里的声音";
+"必需" = "必需";
+"用于生成字幕,不会录制屏幕画面" = "用于生成字幕,不会录制屏幕画面";
+"麦克风" = "麦克风";
+"可选" = "可选";
+"仅在同声传译时使用" = "仅在同声传译时使用";
+"已打开" = "已打开";
+"去开启" = "去开启";
+"已允许" = "已允许";
+"允许" = "允许";
+"去打开" = "去打开";
+"字幕条可任意拖动,拖拽右下角可调整大小。" = "字幕条可任意拖动,拖拽右下角可调整大小。";
+"放一段视频试试" = "放一段视频试试";
+"点击播放,看看实时字幕效果。" = "点击播放,看看实时字幕效果。";
+"播放示例视频" = "播放示例视频";
+"示例 · 0:07" = "示例 · 0:07";
+"正在听…" = "正在听…";
+"听到" = "听到";
+"自动 · %@" = "自动 · %@";
+"最后一步:在会议软件中,将麦克风选为 " = "最后一步:在会议软件中,将麦克风选为 ";
+"想让对方听懂你?" = "想让对方听懂你?";
+"按住说%@,对方听到翻译后的语音。" = "按住说%@,对方听到翻译后的语音。";
+"可在设置中更改" = "可在设置中更改";
+"右侧 option" = "右侧 option";
+"按住说话" = "按住说话";
+
+/* Overlay */
+"你在说… " = "你在说… ";
+"翻译中… " = "翻译中… ";
+"你:" = "你:";
+
+/* SessionStore */
+"会议 %@" = "会议 %@";
+"不到 1 分钟" = "不到 1 分钟";
+"待办" = "待办";
+
+/* SettingsWindow */
+"语言" = "语言";
+"AI 服务" = "AI 服务";
+"诊断" = "诊断";
+"原文 + 译文" = "原文 + 译文";
+"恢复默认(%@)" = "恢复默认(%@)";
+"按 esc 取消" = "按 esc 取消";
+"点击更换按键" = "点击更换按键";
+"按下组合键,或单按右 ⌥" = "按下组合键,或单按右 ⌥";
+"按下新的组合键" = "按下新的组合键";
+"还差一步:允许“输入监控”" = "还差一步:允许“输入监控”";
+"“按住右 ⌥ 说话”需要此权限。请在系统设置中勾选 %@,返回此处即可生效" = "“按住右 ⌥ 说话”需要此权限。请在系统设置中勾选 %@,返回此处即可生效";
+"去允许" = "去允许";
+"知了" = "知了";
+"再试一次" = "再试一次";
+"虚拟麦克风已就绪" = "虚拟麦克风已就绪";
+"%@ · 试音通过,对方听得到" = "%@ · 试音通过,对方听得到";
+"安装" = "安装";
+"输一次电脑密码" = "输一次电脑密码";
+"正在下载…" = "正在下载…";
+"正在安装…" = "正在安装…";
+"让系统认出它" = "让系统认出它";
+"声音会短暂中断约 1 秒" = "声音会短暂中断约 1 秒";
+"正在让系统认出它…" = "正在让系统认出它…";
+"试音" = "试音";
+"自动播一句,确认对方听得到" = "自动播一句,确认对方听得到";
+"正在试音…" = "正在试音…";
+"虚拟麦克风" = "虚拟麦克风";
+"进行中" = "进行中";
+"没装" = "没装";
+"系统还没认出" = "系统还没认出";
+"还没试音" = "还没试音";
+"没听到声音" = "没听到声音";
+"一键安装" = "一键安装";
+"对方会听到:" = "对方会听到:";
+"一段声音" = "一段声音";
+"虚拟麦克风未收到声音,请再试一次" = "虚拟麦克风未收到声音,请再试一次";
+"按住说话,松开后约 2 秒,对方听到译文" = "按住说话,松开后约 2 秒,对方听到译文";
+"在会议软件中,将麦克风选为「%@」。" = "在会议软件中,将麦克风选为「%@」。";
+"把我的话翻译给对方听" = "把我的话翻译给对方听";
+"单独按住右侧 ⌥;与其他键同时按不会触发" = "单独按住右侧 ⌥;与其他键同时按不会触发";
+"说%@,对方听到%@" = "说%@,对方听到%@";
+"声音输出到" = "声音输出到";
+"把我说的翻译给对方" = "把我说的翻译给对方";
+"修改" = "修改";
+"虚拟麦克风(自动)" = "虚拟麦克风(自动)";
+"听的时候显示" = "听的时候显示";
+"选择任意模式都会正常保存记录、生成纪要" = "选择任意模式都会正常保存记录、生成纪要";
+"切换显示方式" = "切换显示方式";
+"被其他应用占用了,点右边换一个" = "被其他应用占用了,点右边换一个";
+"实时纪要 → 字幕条 → 不显示" = "实时纪要 → 字幕条 → 不显示";
+"显示方式" = "显示方式";
+"字幕条显示时机" = "字幕条显示时机";
+"安静多久后收起" = "安静多久后收起";
+"位置和大小" = "位置和大小";
+"鼠标悬停可拖动位置,拖拽右下角可缩放大小" = "鼠标悬停可拖动位置,拖拽右下角可缩放大小";
+"有人说话时" = "有人说话时";
+"始终显示" = "始终显示";
+"2 秒" = "2 秒";
+"4 秒" = "4 秒";
+"8 秒" = "8 秒";
+"恢复默认" = "恢复默认";
+"保存会议录音" = "保存会议录音";
+"只存在这台 Mac 上" = "只存在这台 Mac 上";
+"记录文件夹" = "记录文件夹";
+"首次引导" = "首次引导";
+"打开" = "打开";
+"重新看" = "重新看";
+
+/* Shortcuts */
+"右 ⌥" = "右 ⌥";
+"请包含 ⌃ 或 ⌘,否则会影响正常打字" = "请包含 ⌃ 或 ⌘,否则会影响正常打字";
+
+/* SpeakEngine */
+"无法准备语音识别:%@" = "无法准备语音识别:%@";
+"语音识别仍在准备中,请再按一次" = "语音识别仍在准备中,请再按一次";
+"没有可用的麦克风" = "没有可用的麦克风";
+"麦克风无法启动,请在系统设置里允许%@使用麦克风" = "麦克风无法启动,请在系统设置里允许%@使用麦克风";
+"翻译失败,这句话未发送" = "翻译失败,这句话未发送";
+
+/* SystemAudioTap */
+"无法启动音频采集(%d)" = "无法启动音频采集(%d)";
+"无法初始化音频单元(%d)" = "无法初始化音频单元(%d)";
+"无法设置音频回调(%d)" = "无法设置音频回调(%d)";
+"无法设置音频格式(%d)" = "无法设置音频格式(%d)";
+"无法创建音频格式" = "无法创建音频格式";
+"无法连接音频聚合设备(%d)" = "无法连接音频聚合设备(%d)";
+"无法创建音频单元(%d)" = "无法创建音频单元(%d)";
+"找不到 HAL 音频组件" = "找不到 HAL 音频组件";
+"无法创建音频聚合设备(%d)" = "无法创建音频聚合设备(%d)";
+"找不到默认输出设备" = "找不到默认输出设备";
+"无法创建系统音频 Tap(%d)" = "无法创建系统音频 Tap(%d)";
+
+/* Views */
+"自动识别(%@)" = "自动识别(%@)";
+"%@(需下载)" = "%@(需下载)";
+"系统" = "系统";
+"仅本场" = "仅本场";
+"按住" = "按住";
+"说%@ → %@" = "说%@ → %@";
+"虚拟麦克风尚未设置好,对方听不到你的声音" = "虚拟麦克风尚未设置好,对方听不到你的声音";
+"纪要、文字记录和字幕都在一个窗口里" = "纪要、文字记录和字幕都在一个窗口里";
+"填入 API key 后可生成纪要;文字记录照常保存" = "填入 API key 后可生成纪要;文字记录照常保存";
+"有人说话时显示" = "有人说话时显示";
+"收起前等待" = "收起前等待";
+"搜索标题和原话" = "搜索标题和原话";
+"开启字幕后,每场会议都会自动保存在这里。" = "开启字幕后,每场会议都会自动保存在这里。";
+"没有找到“%@”" = "没有找到“%@”";
+"今天" = "今天";
+"昨天" = "昨天";
+"本周" = "本周";
+"正在记录 · %@ 起 · %lld 句" = "正在记录 · %@ 起 · %lld 句";
+"在 Finder 中显示" = "在 Finder 中显示";
+"恢复自动标题" = "恢复自动标题";
+"删除" = "删除";
+"%lld 小时" = "%lld 小时";
+"%lld 小时 %lld 分" = "%lld 小时 %lld 分";
+"英语" = "英语";
+"日语" = "日语";
+"中文" = "中文";
+"繁中" = "繁中";
+"韩语" = "韩语";
+"西语" = "西语";
+"法语" = "法语";
+"德语" = "德语";
+"葡语" = "葡语";
+"打开开关开始听" = "打开开关开始听";
+"正在听,说话的内容会出现在这里" = "正在听,说话的内容会出现在这里";
+"这场会议没有记录到内容" = "这场会议没有记录到内容";
+"还没有会议记录" = "还没有会议记录";
+"开启字幕后,每场会议都会自动保存一份双语记录。" = "开启字幕后,每场会议都会自动保存一份双语记录。";
+"译文" = "译文";
+"复制为 Markdown" = "复制为 Markdown";
+"导出 Markdown…" = "导出 Markdown…";
+"导出 Word…" = "导出 Word…";
+"导出字幕 SRT…" = "导出字幕 SRT…";
+"标题" = "标题";
+"完整版纪要" = "完整版纪要";
+"速记版纪要" = "速记版纪要";
+"翻译中…" = "翻译中…";
+"正在整理纪要…" = "正在整理纪要…";
+"纪要会在会议进行中自动生成" = "纪要会在会议进行中自动生成";
+"使用 Ling 将文字记录整理为总结、议题、结论和人名,约需半分钟。" = "使用 Ling 将文字记录整理为总结、议题、结论和人名,约需半分钟。";
+"前往 设置 › AI 服务 填入 Ling 的 API key 后即可生成。" = "前往 设置 › AI 服务 填入 Ling 的 API key 后即可生成。";
+"正在生成…" = "正在生成…";
+"生成纪要" = "生成纪要";
+"去填 key" = "去填 key";
+
+/* VirtualMic */
+"%@要安装虚拟麦克风,让会议里的人听到你的翻译。" = "%@要安装虚拟麦克风,让会议里的人听到你的翻译。";
+"安装包校验未通过,已中止安装" = "安装包校验未通过,已中止安装";
+"下载失败,请检查网络" = "下载失败,请检查网络";
+"安装未完成,请再试一次" = "安装未完成,请再试一次";
+"系统还没认出它,点“让系统认出它”再试一次" = "系统还没认出它,点“让系统认出它”再试一次";
+"%@要让系统认出虚拟麦克风,声音会断约 1 秒。" = "%@要让系统认出虚拟麦克风,声音会断约 1 秒。";
+"试音要用麦克风权限,请在系统设置里允许%@" = "试音要用麦克风权限,请在系统设置里允许%@";
+"打不开虚拟麦克风,点“让系统认出它”后再试" = "打不开虚拟麦克风,点“让系统认出它”后再试";
+
+/* VoicePicker */
+"每种语言会记住你选的声音。对方当前在说%@。" = "每种语言会记住你选的声音。对方当前在说%@。";
+"对方听到的声音" = "对方听到的声音";
+"未填写 Ling key 时仅可使用系统声音;填入 key 后可使用 Ming 语音或克隆你自己的声音。" = "未填写 Ling key 时仅可使用系统声音;填入 key 后可使用 Ming 语音或克隆你自己的声音。";
+"录音仅保存在本机,每次发言时随文字发送给 Ling 合成语音;Ling 不可用时自动切回系统声音。" = "录音仅保存在本机,每次发言时随文字发送给 Ling 合成语音;Ling 不可用时自动切回系统声音。";
+"Ming 语音需使用 Ling key,延迟约 1.5 秒;Ling 不可用时自动切回系统声音。" = "Ming 语音需使用 Ling key,延迟约 1.5 秒;Ling 不可用时自动切回系统声音。";
+"更多…" = "更多…";
+"试听" = "试听";
+"需要 Ling key" = "需要 Ling key";
+"用这个" = "用这个";
+"重录" = "重录";
+"录制" = "录制";
+"我自己的声音" = "我自己的声音";
+"已录好 · %lld 秒 · %@" = "已录好 · %lld 秒 · %@";
+"录制 15 秒原声,让对方听到你的音色;说外语时会保留你的口音,延迟约 3 秒" = "录制 15 秒原声,让对方听到你的音色;说外语时会保留你的口音,延迟约 3 秒";
+"说%@最像你,晚约 3 秒" = "说%@最像你,晚约 3 秒";
+"说%@会带你的口音,晚约 3 秒" = "说%@会带你的口音,晚约 3 秒";
+"录制你的声音" = "录制你的声音";
+"请用平时开会的自然语气朗读以下段落,约 15 秒,在安静环境下录制效果最佳。" = "请用平时开会的自然语气朗读以下段落,约 15 秒,在安静环境下录制效果最佳。";
+"这是我自己的声音。只在我说话时用它替我翻译。" = "这是我自己的声音。只在我说话时用它替我翻译。";
+"读完了" = "读完了";
+"开始录" = "开始录";
+"再录一次" = "再录一次";
+"正在听写…" = "正在听写…";
+"%lld–%lld 秒" = "%lld–%lld 秒";
+"需先在“AI 服务”中填入 Ling key,才能使用你自己的声音。" = "需先在“AI 服务”中填入 Ling key,才能使用你自己的声音。";
+"听起来不像或有杂音?换个安静的地方重录一次。录音仅保存在本机,可随时删除。" = "听起来不像或有杂音?换个安静的地方重录一次。录音仅保存在本机,可随时删除。";
+"录好了,先听听像不像" = "录好了,先听听像不像";
+"%lld 秒 · 识别出的文字会与录音一起用于学习你的音色" = "%lld 秒 · 识别出的文字会与录音一起用于学习你的音色";
+"你的原声" = "你的原声";
+"用你的声音说%@" = "用你的声音说%@";
+"对方会听到这个" = "对方会听到这个";
+"用这个声音" = "用这个声音";
+
+/* Voices */
+"女" = "女";
+"美式" = "美式";
+"自然对话" = "自然对话";
+"男" = "男";
+"英式" = "英式";
+"稳重" = "稳重";
+"平稳" = "平稳";
+"清亮" = "清亮";
+"播报" = "播报";
+"温和" = "温和";
+"沉稳" = "沉稳";
+"温暖" = "温暖";
+"亲切" = "亲切";
+"沉着" = "沉着";
+"清楚" = "清楚";
+"高品质" = "高品质";
+"增强" = "增强";
+"标准" = "标准";
+"麦克风没收到声音,请检查麦克风权限" = "麦克风没收到声音,请检查麦克风权限";
+"无法打开麦克风:%@" = "无法打开麦克风:%@";
+"录音太短了,请至少朗读 %lld 秒" = "录音太短了,请至少朗读 %lld 秒";
+"没听清录音内容,请换个安静的地方再录一次" = "没听清录音内容,请换个安静的地方再录一次";
diff --git a/Sources/LiveSubs/AISettings.swift b/Sources/LiveSubs/AISettings.swift
index 0aa2cd2..71a7752 100644
--- a/Sources/LiveSubs/AISettings.swift
+++ b/Sources/LiveSubs/AISettings.swift
@@ -15,18 +15,18 @@ struct AISettingsView: View {
Text("用在哪里").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.secondary)
.padding(.top, 4)
SettingsCard {
- usageRow("实时纪要", tag: ling.usable ? "用 Ling" : "需要 key", on: ling.usable,
- note: ling.usable ? "会中每 45 秒更新" : "填好 key 后可用")
- usageRow("翻译", tag: ling.usable ? "用 Ling" : "Google", on: ling.usable,
- note: ling.usable ? "整句用 Ling;不行时换 Google、本机" : "没有 key 时照常可用")
- usageRow("语音识别", tag: "本机", on: false, note: "更快,不花钱")
- SettingsRow(title: "同声传译的声音", detail: ling.usable ? "Ming 的声音或你自己的声音" : "没有 key 时用本机声音",
+ usageRow(L("实时纪要"), tag: ling.usable ? L("用 Ling") : L("需要 key"), on: ling.usable,
+ note: ling.usable ? L("会中每 45 秒更新") : L("填好 key 后可用"))
+ usageRow(L("翻译"), tag: ling.usable ? L("用 Ling") : "Google", on: ling.usable,
+ note: ling.usable ? L("整句用 Ling;不行时换 Google、本机") : L("没有 key 时照常可用"))
+ usageRow(L("语音识别"), tag: L("本机"), on: false, note: L("更快,不花钱"))
+ SettingsRow(title: L("同声传译的声音"), detail: ling.usable ? L("Ming 的声音或你自己的声音") : L("没有 key 时用本机声音"),
divider: false) {
- SoftButton("去选声音") { model.settingsSection = .speak }
+ SoftButton(L("去选声音")) { model.settingsSection = .speak }
}
}
SettingsCard {
- SettingsRow(title: "模型", detail: "3.1 更准;3.0 更快、更省", divider: false) {
+ SettingsRow(title: L("模型"), detail: L("3.1 更准;3.0 更快、更省"), divider: false) {
PillMenu(value: settings.aiModel, options: LingClient.models.map { ($0, $0) }) { settings.aiModel = $0 }
}
}
@@ -53,9 +53,9 @@ struct AISettingsView: View {
.padding(.horizontal, 12).frame(maxWidth: .infinity, minHeight: 36, alignment: .leading)
.background(RoundedRectangle(cornerRadius: 10).fill(Color.white))
.overlay(RoundedRectangle(cornerRadius: 10).stroke(Palette.line, lineWidth: 1))
- SoftButton("更换") { draft = ""; editing = true }
+ SoftButton(L("更换")) { draft = ""; editing = true }
if case .invalid = ling.keyState {} else if case .unreachable = ling.keyState {
- SoftButton("重试") { Task { await ling.check() } }
+ SoftButton(L("重试")) { Task { await ling.check() } }
}
}
} else {
@@ -70,8 +70,8 @@ struct AISettingsView: View {
.background(RoundedRectangle(cornerRadius: 10).fill(Color.white))
.overlay(RoundedRectangle(cornerRadius: 10).stroke(Palette.ink.opacity(0.6), lineWidth: 1))
.onSubmit(save)
- SoftButton("保存并检查", dark: true, action: save)
- if editing { SoftButton("取消") { editing = false } }
+ SoftButton(L("保存并检查"), dark: true, action: save)
+ if editing { SoftButton(L("取消")) { editing = false } }
}
Button("打开 Ling 开放平台 ↗") {
if let url = URL(string: "https://chat.ant-ling.com/open") { NSWorkspace.shared.open(url) }
@@ -112,20 +112,20 @@ struct AISettingsView: View {
private var statusTitle: String {
switch ling.keyState {
- case .none: "还没填 API key"
- case .unchecked, .checking: "正在检查…"
- case .ok: "已连接"
- case .invalid: "这个 key 用不了"
- case .unreachable: "暂时连不上"
+ case .none: L("还没填 API key")
+ case .unchecked, .checking: L("正在检查…")
+ case .ok: L("已连接")
+ case .invalid: L("这个 key 用不了")
+ case .unreachable: L("暂时连不上")
}
}
private var statusDetail: String? {
switch ling.keyState {
- case .ok(let s): "\(settings.aiModel) · 响应约 \(String(format: "%.1f", s)) 秒"
- case .invalid: "Ling 提示此令牌无效,请检查是否复制完整,或重新创建一个"
+ case .ok(let s): L("\(settings.aiModel) · 响应约 \(String(format: "%.1f", s)) 秒")
+ case .invalid: L("Ling 提示此令牌无效,请检查是否复制完整,或重新创建一个")
case .unreachable(let why): why
- case .none: "不填 key 时,字幕和翻译仍可正常使用"
+ case .none: L("不填 key 时,字幕和翻译仍可正常使用")
default: nil
}
}
diff --git a/Sources/LiveSubs/AppMenu.swift b/Sources/LiveSubs/AppMenu.swift
index e1f4645..306c19e 100644
--- a/Sources/LiveSubs/AppMenu.swift
+++ b/Sources/LiveSubs/AppMenu.swift
@@ -19,70 +19,70 @@ final class AppMenu: NSObject, NSMenuItemValidation {
let main = NSMenu()
let app = NSMenu(title: name)
- app.addItem(item("关于 \(name)", #selector(about)))
+ app.addItem(item(L("关于 \(name)"), #selector(about)))
app.addItem(.separator())
- app.addItem(item("设置…", #selector(openSettings), ","))
- app.addItem(item("AI 服务…", #selector(openAI)))
+ app.addItem(item(L("设置…"), #selector(openSettings), ","))
+ app.addItem(item(L("AI 服务…"), #selector(openAI)))
app.addItem(.separator())
- app.addItem(item("隐藏 \(name)", #selector(NSApplication.hide(_:)), "h", target: NSApp))
- app.addItem(item("隐藏其他", #selector(NSApplication.hideOtherApplications(_:)), "h", [.command, .option], target: NSApp))
- app.addItem(item("全部显示", #selector(NSApplication.unhideAllApplications(_:)), target: NSApp))
+ app.addItem(item(L("隐藏 \(name)"), #selector(NSApplication.hide(_:)), "h", target: NSApp))
+ app.addItem(item(L("隐藏其他"), #selector(NSApplication.hideOtherApplications(_:)), "h", [.command, .option], target: NSApp))
+ app.addItem(item(L("全部显示"), #selector(NSApplication.unhideAllApplications(_:)), target: NSApp))
app.addItem(.separator())
- app.addItem(item("退出 \(name)", #selector(NSApplication.terminate(_:)), "q", target: NSApp))
+ app.addItem(item(L("退出 \(name)"), #selector(NSApplication.terminate(_:)), "q", target: NSApp))
add(app, to: main)
- let notes = NSMenu(title: "纪要")
- notes.addItem(item("停止记录", #selector(toggleRecording), "r"))
- notes.addItem(item("立即更新纪要", #selector(updateNotes), "u"))
- notes.addItem(item("收起后的新内容", #selector(catchUp), "j"))
+ let notes = NSMenu(title: L("纪要"))
+ notes.addItem(item(L("停止记录"), #selector(toggleRecording), "r"))
+ notes.addItem(item(L("立即更新纪要"), #selector(updateNotes), "u"))
+ notes.addItem(item(L("收起后的新内容"), #selector(catchUp), "j"))
notes.addItem(.separator())
- notes.addItem(item("复制纪要", #selector(copyNotes), "c", [.command, .shift]))
- let export = NSMenu(title: "导出")
+ notes.addItem(item(L("复制纪要"), #selector(copyNotes), "c", [.command, .shift]))
+ let export = NSMenu(title: L("导出"))
export.addItem(item("Markdown…", #selector(exportNotes(_:)), "e", tag: 0))
export.addItem(item("Word…", #selector(exportNotes(_:)), tag: 1))
- export.addItem(item("SRT 字幕…", #selector(exportNotes(_:)), tag: 2))
- let exportItem = NSMenuItem(title: "导出", action: nil, keyEquivalent: "")
+ export.addItem(item(L("SRT 字幕…"), #selector(exportNotes(_:)), tag: 2))
+ let exportItem = NSMenuItem(title: L("导出"), action: nil, keyEquivalent: "")
exportItem.submenu = export
notes.addItem(exportItem)
notes.addItem(.separator())
- notes.addItem(item("会议记录", #selector(openRecords), "0"))
+ notes.addItem(item(L("会议记录"), #selector(openRecords), "0"))
add(notes, to: main)
- let display = NSMenu(title: "显示")
- display.addItem(item("实时纪要", #selector(setDisplay(_:)), tag: 0))
- display.addItem(item("字幕条", #selector(setDisplay(_:)), tag: 1))
- display.addItem(item("不显示", #selector(setDisplay(_:)), tag: 2))
+ let display = NSMenu(title: L("显示"))
+ display.addItem(item(L("实时纪要"), #selector(setDisplay(_:)), tag: 0))
+ display.addItem(item(L("字幕条"), #selector(setDisplay(_:)), tag: 1))
+ display.addItem(item(L("不显示"), #selector(setDisplay(_:)), tag: 2))
display.addItem(.separator())
- display.addItem(item("小卡", #selector(setSize(_:)), "1", tag: 0))
- display.addItem(item("侧栏", #selector(setSize(_:)), "2", tag: 1))
- display.addItem(item("纪要和原话并排", #selector(setSize(_:)), "3", tag: 2))
+ display.addItem(item(L("小卡"), #selector(setSize(_:)), "1", tag: 0))
+ display.addItem(item(L("侧栏"), #selector(setSize(_:)), "2", tag: 1))
+ display.addItem(item(L("纪要和原话并排"), #selector(setSize(_:)), "3", tag: 2))
display.addItem(.separator())
- display.addItem(item("始终置顶", #selector(toggleOnTop)))
+ display.addItem(item(L("始终置顶"), #selector(toggleOnTop)))
add(display, to: main)
// Standard actions with no target go down the responder chain (text fields, selectable text).
- let edit = NSMenu(title: "编辑")
- edit.addItem(item("撤销", Selector(("undo:")), "z", chain: true))
- edit.addItem(item("重做", Selector(("redo:")), "z", [.command, .shift], chain: true))
+ let edit = NSMenu(title: L("编辑"))
+ edit.addItem(item(L("撤销"), Selector(("undo:")), "z", chain: true))
+ edit.addItem(item(L("重做"), Selector(("redo:")), "z", [.command, .shift], chain: true))
edit.addItem(.separator())
- edit.addItem(item("剪切", #selector(NSText.cut(_:)), "x", chain: true))
- edit.addItem(item("拷贝", #selector(NSText.copy(_:)), "c", chain: true))
- edit.addItem(item("粘贴", #selector(NSText.paste(_:)), "v", chain: true))
- edit.addItem(item("全选", #selector(NSText.selectAll(_:)), "a", chain: true))
+ edit.addItem(item(L("剪切"), #selector(NSText.cut(_:)), "x", chain: true))
+ edit.addItem(item(L("拷贝"), #selector(NSText.copy(_:)), "c", chain: true))
+ edit.addItem(item(L("粘贴"), #selector(NSText.paste(_:)), "v", chain: true))
+ edit.addItem(item(L("全选"), #selector(NSText.selectAll(_:)), "a", chain: true))
edit.addItem(.separator())
- edit.addItem(item("搜索文字记录", #selector(search), "f"))
+ edit.addItem(item(L("搜索文字记录"), #selector(search), "f"))
add(edit, to: main)
- let window = NSMenu(title: "窗口")
- window.addItem(item("最小化", #selector(NSWindow.performMiniaturize(_:)), "m", chain: true))
- window.addItem(item("关闭", #selector(NSWindow.performClose(_:)), "w", chain: true))
+ let window = NSMenu(title: L("窗口"))
+ window.addItem(item(L("最小化"), #selector(NSWindow.performMiniaturize(_:)), "m", chain: true))
+ window.addItem(item(L("关闭"), #selector(NSWindow.performClose(_:)), "w", chain: true))
window.addItem(.separator())
- window.addItem(item("实时纪要", #selector(openNotes)))
- window.addItem(item("会议记录", #selector(openRecords)))
+ window.addItem(item(L("实时纪要"), #selector(openNotes)))
+ window.addItem(item(L("会议记录"), #selector(openRecords)))
add(window, to: main)
- let help = NSMenu(title: "帮助")
- help.addItem(item("新手引导", #selector(onboarding)))
+ let help = NSMenu(title: L("帮助"))
+ help.addItem(item(L("新手引导"), #selector(onboarding)))
add(help, to: main)
NSApp.mainMenu = main
@@ -114,7 +114,7 @@ final class AppMenu: NSObject, NSMenuItemValidation {
let session = model.store.session(model.store.liveID ?? model.notes.shownID)
switch item.action {
case #selector(toggleRecording):
- item.title = model.running ? "停止记录" : "开始记录"
+ item.title = model.running ? L("停止记录") : L("开始记录")
return true
case #selector(updateNotes):
return model.store.liveID != nil && model.ling.hasKey && model.notes.state != .updating
diff --git a/Sources/LiveSubs/AppModel.swift b/Sources/LiveSubs/AppModel.swift
index 32e6637..c08bde5 100644
--- a/Sources/LiveSubs/AppModel.swift
+++ b/Sources/LiveSubs/AppModel.swift
@@ -17,7 +17,7 @@ final class AppModel: ObservableObject {
lazy var speak = SpeakEngine(settings: settings)
@Published var running = false
- @Published var status = "准备就绪"
+ @Published var status = L("准备就绪")
@Published var summary = ""
@Published var installed: Set<String> = []
@Published var candidates: [Lang] = []
@@ -115,7 +115,7 @@ final class AppModel: ObservableObject {
guard self.settings.displayMode == "bar" else {
// The notes window's caption line shows what you are saying.
if phase != .idle || !src.isEmpty {
- self.liveSource = src.isEmpty ? "你正在说…" : "你:\(src)"
+ self.liveSource = src.isEmpty ? L("你正在说…") : L("你:\(src)")
self.liveTranslation = dst
}
return
@@ -173,7 +173,8 @@ final class AppModel: ObservableObject {
func refresh() {
running = listen.isRunning
- systemAudioOK = listen.isRunning
+ // Once the tap has run, the permission is there: pausing doesn't take it away.
+ systemAudioOK = systemAudioOK || listen.isRunning
summary = listen.languageSummary()
candidates = listen.candidates
installed = listen.installedLocales
@@ -193,7 +194,7 @@ final class AppModel: ObservableObject {
if mic != micStatus { micStatus = mic }
let devices = AudioDevices.outputs()
if devices.map(\.uid) != outputs.map(\.uid) { outputs = devices }
- if systemAudioOK != listen.isRunning { systemAudioOK = listen.isRunning }
+ if listen.isRunning && !systemAudioOK { systemAudioOK = true }
}
/// Starting the tap triggers the system prompt; if it still fails, open the pane.
@@ -263,6 +264,7 @@ final class AppModel: ObservableObject {
}
func stop() {
+ diagnostics.end()
listen.stop()
listen.router.setRecording(nil)
speak.setRecording(nil)
@@ -280,10 +282,10 @@ final class AppModel: ObservableObject {
guard listen.isRunning, let id = store.liveID, let s = store.session(id), !s.lines.isEmpty else { stop(); return }
NSApp.activate()
let alert = NSAlert()
- alert.messageText = "结束这场会议?"
- alert.informativeText = "已记录 \(NotesEngine.clock(Date().timeIntervalSince(s.startedAt))) · \(s.lines.count) 句。结束后停止收听,并整理一份完整版纪要。"
- let end = alert.addButton(withTitle: "结束会议")
- let keep = alert.addButton(withTitle: "继续记录")
+ alert.messageText = L("结束这场会议?")
+ alert.informativeText = L("已记录 \(NotesEngine.clock(Date().timeIntervalSince(s.startedAt))) · \(s.lines.count) 句。结束后停止收听,并整理一份完整版纪要。")
+ let end = alert.addButton(withTitle: L("结束会议"))
+ let keep = alert.addButton(withTitle: L("继续记录"))
end.hasDestructiveAction = true
end.keyEquivalent = ""
keep.keyEquivalent = "\r"
@@ -394,6 +396,16 @@ final class AppModel: ObservableObject {
}
}
+ /// The user closed the notes window: show the same meeting in the records window.
+ func notesWindowClosed() {
+ let id = store.liveID ?? notes.shownID
+ openMainWindow?()
+ if let id {
+ mainShow = nil
+ mainShow = "\(id),notes"
+ }
+ }
+
func openNotesWindow() {
if settings.displayMode != "notes" { setDisplayMode("notes") }
notesWindow.show()
@@ -495,17 +507,19 @@ final class AppModel: ObservableObject {
/// Validates and saves a new shortcut. Returns why it was refused, or nil.
func setShortcut(_ s: Shortcut, for role: ShortcutRole) -> String? {
- if role == .toggle && s.isRightOption { return "右 ⌥ 只能用于“按住说话”" }
+ if role == .toggle && s.isRightOption { return L("右 ⌥ 只能用于“按住说话”") }
if let p = s.typingProblem { return p }
let other = role == .talk ? settings.toggleKey : settings.talkKey
- if s == other { return "与另一个快捷键冲突" }
- if s.isSystemShortcut { return "\(s.display) 是系统快捷键,换一个吧" }
- if !s.isRightOption {
+ if s == other { return L("与另一个快捷键冲突") }
+ if s.isSystemShortcut { return L("\(s.display) 是系统快捷键,换一个吧") }
+ // The one already in use is registered by us: probing it would always fail.
+ let current = role == .talk ? settings.talkKey : settings.toggleKey
+ if !s.isRightOption && s != current {
// Probe: Carbon refuses a combo another app already registered.
let probe = HotKey(id: 9, shortcut: s)
let free = probe.register()
probe.unregister()
- if !free { return "\(s.display) 已被其他应用占用,换一个吧" }
+ if !free { return L("\(s.display) 已被其他应用占用,换一个吧") }
}
switch role {
case .talk:
@@ -717,6 +731,7 @@ final class AppModel: ObservableObject {
case "notesReplay": Task { await notes.replay(arg) }
case "notesShow": notes.show(arg)
case "notesCapturable": notesWindow.setCapturable(arg != "off")
+ case "notesClose": notesWindow.performClose()
case "notesRender":
// The whole notes column as a PNG, for checking what is below the fold.
let view = NotesContentView(notes: notes.notes, fresh: notes.fresh, live: store.liveID != nil,
@@ -743,6 +758,26 @@ final class AppModel: ObservableObject {
try? full.representation(using: .png, properties: [:])?.write(to: URL(fileURLWithPath: arg + ".notes.png"))
}
}
+ case "settingsRender":
+ // settingsRender:<section>=<png>: one settings page in full, scroll view or not.
+ let p = arg.split(separator: "=", maxSplits: 1).map(String.init)
+ guard p.count == 2, let section = SettingsSection(rawValue: p[0]) else { break }
+ settingsSection = section
+ let r = ImageRenderer(content: SettingsView(model: self, settings: settings, installer: installer).page
+ .frame(width: 530).background(Color(red: 0.965, green: 0.969, blue: 0.976)))
+ r.scale = 2
+ if let img = r.nsImage, let tiff = img.tiffRepresentation, let rep = NSBitmapImageRep(data: tiff) {
+ try? rep.representation(using: .png, properties: [:])?.write(to: URL(fileURLWithPath: p[1]))
+ }
+ case "windowsRender":
+ // Every visible window as drawn (<dir>/<n>-<class>.png), without Screen Recording permission.
+ for (i, w) in NSApp.windows.enumerated() where w.isVisible {
+ guard let view = w.contentView, view.bounds.width > 40,
+ let rep = view.bitmapImageRepForCachingDisplay(in: view.bounds) else { continue }
+ view.cacheDisplay(in: view.bounds, to: rep)
+ let name = "\(i)-\(String(describing: type(of: w)).prefix(24)).png"
+ try? rep.representation(using: .png, properties: [:])?.write(to: URL(fileURLWithPath: arg).appendingPathComponent(name))
+ }
case "notesState": debugLog("notes state=\(notes.state) topics=\(notes.notes.topics.count) covered=\(notes.notes.covered) glossary=\(notes.glossary.count) timedPoints=\(notes.notes.topics.reduce(0) { $0 + ($1.pointTimes?.compactMap { $0 }.count ?? 0) })/\(notes.notes.topics.reduce(0) { $0 + $1.points.count }) fresh=\(notes.fresh.count)")
case "lingSimulate":
ling.simulate = ["429": .rateLimited, "hijack": .hijacked, "timeout": .timeout][arg]
@@ -851,10 +886,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
guard model.running, let id = model.store.liveID, !(model.store.session(id)?.lines.isEmpty ?? true) else { return .terminateNow }
NSApp.activate()
let alert = NSAlert()
- alert.messageText = "正在记录会议"
- alert.informativeText = "退出会结束这场记录,已记下的内容会保存。"
- alert.addButton(withTitle: "退出")
- alert.addButton(withTitle: "取消")
+ alert.messageText = L("正在记录会议")
+ alert.informativeText = L("退出会结束这场记录,已记下的内容会保存。")
+ alert.addButton(withTitle: L("退出"))
+ alert.addButton(withTitle: L("取消"))
return alert.runModal() == .alertFirstButtonReturn ? .terminateNow : .terminateCancel
}
@@ -877,9 +912,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
}
popover.behavior = .transient
popover.animates = false
- popover.contentViewController = NSHostingController(
- rootView: MenuPanelView(model: model, settings: model.settings)
- )
+ let panel = NSHostingController(rootView: MenuPanelView(model: model, settings: model.settings))
+ // The popover follows the panel's height as it changes (a status line, the virtual-mic
+ // warning). Without this the hosting view resized the popover window from its bottom
+ // edge, pushing the top of the panel above the screen.
+ panel.sizingOptions = .preferredContentSize
+ popover.contentViewController = panel
}
@objc private func togglePopover() {
@@ -924,7 +962,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
let w = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 720, height: 600),
styleMask: [.titled, .closable, .fullSizeContentView],
backing: .buffered, defer: false)
- w.title = "设置"
+ w.title = L("设置")
w.titlebarAppearsTransparent = true
w.titleVisibility = .hidden
w.isReleasedWhenClosed = false
@@ -946,7 +984,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
let w = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 860, height: 640),
styleMask: [.titled, .closable, .fullSizeContentView],
backing: .buffered, defer: false)
- w.title = "欢迎使用\(appDisplayName)"
+ w.title = L("欢迎使用\(appDisplayName)")
w.titlebarAppearsTransparent = true
w.titleVisibility = .hidden
w.isReleasedWhenClosed = false
diff --git a/Sources/LiveSubs/AudioRouter.swift b/Sources/LiveSubs/AudioRouter.swift
index 0759087..0719ee9 100644
--- a/Sources/LiveSubs/AudioRouter.swift
+++ b/Sources/LiveSubs/AudioRouter.swift
@@ -111,7 +111,7 @@ final class AudioRouter: @unchecked Sendable {
private func record(_ buffer: AVAudioPCMBuffer) {
guard let url = recordURL else { return }
if recorder == nil {
- recorder = AudioFileWriter.open(url, format: buffer.format)
+ recorder = AudioFileWriter.open(AudioFileWriter.partial(url), format: buffer.format)
if recorder == nil { recordURL = nil; return }
}
try? recorder?.write(from: buffer)
@@ -205,4 +205,26 @@ enum AudioFileWriter {
return try? AVAudioFile(forWriting: url, settings: settings,
commonFormat: format.commonFormat, interleaved: format.isInterleaved)
}
+
+ /// Meetings are recorded as ADTS (`system.aac`), which stays readable up to the last packet
+ /// if the app is killed; an .m4a is unreadable until it is closed. `finish` turns it into
+ /// the .m4a afterwards (and at launch, for a meeting the app didn't get to close).
+ static func partial(_ url: URL) -> URL { url.deletingPathExtension().appendingPathExtension("aac") }
+
+ /// Rewraps `partial(url)` into `url` without re-encoding, then removes the partial file.
+ /// A partial file next to an .m4a means the last rewrap was cut short: it is done again.
+ nonisolated static func finish(_ url: URL) async {
+ let src = partial(url)
+ guard FileManager.default.fileExists(atPath: src.path) else { return }
+ try? FileManager.default.removeItem(at: url)
+ let asset = AVURLAsset(url: src)
+ guard let export = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetPassthrough) else { return }
+ do {
+ try await export.export(to: url, as: .m4a)
+ try? FileManager.default.removeItem(at: src)
+ } catch {
+ debugLog("audio rewrap failed \(url.lastPathComponent): \(error)")
+ try? FileManager.default.removeItem(at: url)
+ }
+ }
}
diff --git a/Sources/LiveSubs/Diagnostics.swift b/Sources/LiveSubs/Diagnostics.swift
index ca9ee5a..c936fb9 100644
--- a/Sources/LiveSubs/Diagnostics.swift
+++ b/Sources/LiveSubs/Diagnostics.swift
@@ -61,6 +61,8 @@ final class Diagnostics: ObservableObject {
@Published private(set) var sentences: [SentenceTiming] = []
@Published private(set) var calls: [LingCall] = []
@Published private(set) var startedAt: Date?
+ /// When the meeting stopped: the header stops counting minutes.
+ @Published private(set) var endedAt: Date?
var enabled: () -> Bool = { false }
/// The live meeting's folder, nil when not listening.
@@ -70,8 +72,11 @@ final class Diagnostics: ObservableObject {
sentences = []
calls = []
startedAt = Date()
+ endedAt = nil
}
+ func end() { if startedAt != nil, endedAt == nil { endedAt = Date() } }
+
func record(_ s: SentenceTiming) {
guard enabled() else { return }
sentences.append(s)
@@ -153,17 +158,17 @@ final class Diagnostics: ObservableObject {
/// Plain text for "复制诊断信息": numbers only, safe to paste anywhere.
func report(version: String, model: String) -> String {
func f(_ s: Stat?) -> String { s.map { String(format: "p50 %.2fs p95 %.2fs n=%d", $0.p50, $0.p95, $0.n) } ?? "-" }
- var lines = ["\(appDisplayName) \(version) 诊断 \(Date())", "模型 \(model)"]
- if let startedAt { lines.append(String(format: "本场 %.0f 分钟", Date().timeIntervalSince(startedAt) / 60)) }
- lines.append("说完到出字幕 " + f(endToEnd))
- lines.append("识别定稿 " + f(recognize))
- lines.append("翻译 " + f(translate))
- lines.append("同声传译(松开到译好)" + f(speakBack))
- lines.append("单轮纪要耗时 " + f(notesRounds))
- lines.append("翻译来源 " + viaCounts.map { String(format: "%@ %d (p50 %.2fs)", $0.0, $0.1, $0.2) }.joined(separator: " · "))
- lines.append("换后备 " + (fallbackCounts.isEmpty ? "无" : fallbackCounts.map { "\($0.0) \($0.1)" }.joined(separator: " · ")))
+ var lines = [L("\(appDisplayName) \(version) 诊断 \(Date())"), L("模型 \(model)")]
+ if let startedAt { lines.append(String(format: L("本场 %.0f 分钟"), (endedAt ?? Date()).timeIntervalSince(startedAt) / 60)) }
+ lines.append(L("说完到出字幕 ") + f(endToEnd))
+ lines.append(L("识别定稿 ") + f(recognize))
+ lines.append(L("翻译 ") + f(translate))
+ lines.append(L("同声传译(松开到译好)") + f(speakBack))
+ lines.append(L("单轮纪要耗时 ") + f(notesRounds))
+ lines.append(L("翻译来源 ") + viaCounts.map { String(format: "%@ %d (p50 %.2fs)", $0.0, $0.1, $0.2) }.joined(separator: " · "))
+ lines.append(L("换后备 ") + (fallbackCounts.isEmpty ? L("无") : fallbackCounts.map { "\($0.0) \($0.1)" }.joined(separator: " · ")))
let t = tokens
- lines.append(String(format: "Ling 请求 %d 次 · 排队最久 %.2fs · token %d/%d", calls.count, maxQueue, t.0, t.1))
+ lines.append(String(format: L("Ling 请求 %d 次 · 排队最久 %.2fs · token %d/%d"), calls.count, maxQueue, t.0, t.1))
return lines.joined(separator: "\n")
}
}
@@ -181,18 +186,18 @@ struct DiagnosticsView: View {
VStack(alignment: .leading, spacing: 14) {
Text(subtitle).font(.system(size: 12)).foregroundStyle(Palette.secondary).padding(.top, -8)
HStack(spacing: 8) {
- tile("说完到上屏", diagnostics.endToEnd, dark: true)
- tile("识别定稿", diagnostics.recognize)
- tile("翻译", diagnostics.translate)
- tile("纪要一轮", diagnostics.notesRounds)
+ tile(L("说完到上屏"), diagnostics.endToEnd, dark: true)
+ tile(L("识别定稿"), diagnostics.recognize)
+ tile(L("翻译"), diagnostics.translate)
+ tile(L("纪要一轮"), diagnostics.notesRounds)
}
providers
lingCard
recent
HStack(spacing: 8) {
- SoftButton(copied ? "已复制" : "复制诊断信息", dark: true) { copy() }
+ SoftButton(copied ? L("已复制") : L("复制诊断信息"), dark: true) { copy() }
// The meeting folder holds metrics.jsonl; the log only exists in dev builds or with `debug` on.
- SoftButton(diagnostics.folder() == nil ? "打开日志" : "打开本场数据") {
+ SoftButton(diagnostics.folder() == nil ? L("打开日志") : L("打开本场数据")) {
NSWorkspace.shared.open(diagnostics.folder() ?? URL(fileURLWithPath: DevBuild.logPath))
}
Spacer()
@@ -203,9 +208,9 @@ struct DiagnosticsView: View {
}
private var subtitle: String {
- guard let s = diagnostics.startedAt else { return "开始聆听后,这里会显示每句话的耗时明细" }
- let m = Int(tick.timeIntervalSince(s) / 60)
- return "这场会议 · \(m) 分钟 · \(diagnostics.heard.count) 句 · 同声传译 \(diagnostics.said.count) 次"
+ guard let s = diagnostics.startedAt else { return L("开始聆听后,这里会显示每句话的耗时明细") }
+ let m = Int((diagnostics.endedAt ?? tick).timeIntervalSince(s) / 60)
+ return L("这场会议 · \(m) 分钟 · \(diagnostics.heard.count) 句 · 同声传译 \(diagnostics.said.count) 次")
}
private func tile(_ title: String, _ s: Diagnostics.Stat?, dark: Bool = false) -> some View {
@@ -213,7 +218,7 @@ struct DiagnosticsView: View {
Text(title).font(.system(size: 11)).foregroundStyle(dark ? Color.white.opacity(0.75) : Palette.secondary)
Text(s.map { String(format: "%.1fs", $0.p50) } ?? "—").font(.system(size: 20, weight: .bold).monospacedDigit())
.foregroundStyle(dark ? Color.white : Palette.ink)
- Text(s.map { String(format: "p95 %.1fs · %d", $0.p95, $0.n) } ?? "暂无数据")
+ Text(s.map { String(format: "p95 %.1fs · %d", $0.p95, $0.n) } ?? L("暂无数据"))
.font(.system(size: 11).monospacedDigit()).foregroundStyle(dark ? Color.white.opacity(0.75) : Palette.tertiary)
}
.padding(12).frame(maxWidth: .infinity, alignment: .leading)
@@ -234,23 +239,23 @@ struct DiagnosticsView: View {
switch via {
case "ling": "Ling"
case "google": "Google"
- case "apple": "本机"
- case "ming": "Ming 语音"
- default: "没译出"
+ case "apple": L("本机")
+ case "ming": L("Ming 语音")
+ default: L("没译出")
}
}
private static func reason(_ key: String) -> String {
let parts = key.split(separator: ":").map(String.init)
- let who = parts.first.map { $0 == "ling" ? "Ling" : $0 == "google" ? "Google" : $0 == "notes" ? "纪要" : $0 == "ming" ? "Ming 语音" : "本机" } ?? ""
+ let who = parts.first.map { $0 == "ling" ? "Ling" : $0 == "google" ? "Google" : $0 == "notes" ? L("纪要") : $0 == "ming" ? L("Ming 语音") : L("本机") } ?? ""
let why: String
switch parts.last ?? "" {
- case "hijacked": why = "被搜索劫持"
- case "rateLimited", "429": why = "限流"
- case "timeout": why = "超时"
- case "unparsed": why = "回复格式不对"
- case "network": why = "网络错误"
- case "unavailable": why = "未安装语言包"
+ case "hijacked": why = L("被搜索劫持")
+ case "rateLimited", "429": why = L("限流")
+ case "timeout": why = L("超时")
+ case "unparsed": why = L("回复格式不对")
+ case "network": why = L("网络错误")
+ case "unavailable": why = L("未安装语言包")
default: why = parts.last ?? ""
}
return "\(who) \(why)"
@@ -304,14 +309,14 @@ struct DiagnosticsView: View {
let _ = tick
let t = diagnostics.tokens
return SettingsCard {
- SettingsRow(title: "Ling 请求速度", detail: "账号上限约每秒 2 次") {
- Text(String(format: "%.1f / 2 次每秒", diagnostics.lingRate)).font(.system(size: 12).monospacedDigit())
+ SettingsRow(title: L("Ling 请求速度"), detail: L("账号上限约每秒 2 次")) {
+ Text(String(format: L("%.1f / 2 次每秒"), diagnostics.lingRate)).font(.system(size: 12).monospacedDigit())
.foregroundStyle(Palette.secondary)
}
- SettingsRow(title: "排队最久") {
+ SettingsRow(title: L("排队最久")) {
Text(String(format: "%.1fs", diagnostics.maxQueue)).font(.system(size: 12).monospacedDigit()).foregroundStyle(Palette.secondary)
}
- SettingsRow(title: "本场用量", divider: false) {
+ SettingsRow(title: L("本场用量"), divider: false) {
Text("\(diagnostics.calls.count) 次 · \(t.0 + t.1) token").font(.system(size: 12).monospacedDigit())
.foregroundStyle(Palette.secondary)
}
@@ -329,8 +334,8 @@ struct DiagnosticsView: View {
ForEach(rows) { s in
HStack(spacing: 10) {
VStack(alignment: .leading, spacing: 1) {
- Text("\(Self.clock.string(from: s.at)) \(s.side == "me" ? "你" : "对方")").font(.system(size: 12).monospacedDigit())
- Text(s.fallbacks.isEmpty ? "\(Self.name(s.via)) · \(s.chars) 字" : s.fallbacks.map(Self.reason).joined(separator: "、") + " → " + Self.name(s.via))
+ Text("\(Self.clock.string(from: s.at)) \(s.side == "me" ? L("你") : L("对方"))").font(.system(size: 12).monospacedDigit())
+ Text(s.fallbacks.isEmpty ? L("\(Self.name(s.via)) · \(s.chars) 字") : s.fallbacks.map(Self.reason).joined(separator: "、") + " → " + Self.name(s.via))
.font(.system(size: 10)).foregroundStyle(s.fallbacks.isEmpty ? Palette.tertiary : Palette.accentInk).lineLimit(1)
}
.frame(width: 150, alignment: .leading)
diff --git a/Sources/LiveSubs/LanguageSettings.swift b/Sources/LiveSubs/LanguageSettings.swift
index 7ee5e9b..13da9fc 100644
--- a/Sources/LiveSubs/LanguageSettings.swift
+++ b/Sources/LiveSubs/LanguageSettings.swift
@@ -10,39 +10,39 @@ struct LanguageSettings: View {
var body: some View {
VStack(alignment: .leading, spacing: 14) {
route
- group("听对方") {
- SettingsRow(title: "对方说的语言", detail: heardDetail) {
- PillMenu(value: heardValue, options: [("auto", "自动识别")] + sourceLanguages.map { ($0.locale, $0.name) }) {
+ group(L("听对方")) {
+ SettingsRow(title: L("对方说的语言"), detail: heardDetail) {
+ PillMenu(value: heardValue, options: [("auto", L("自动识别"))] + sourceLanguages.map { ($0.locale, $0.name) }) {
model.sourceSelection = $0
}
}
- SettingsRow(title: "字幕", detail: "只看原文时不翻译,也不用 Ling 额度") {
+ SettingsRow(title: L("字幕"), detail: L("只看原文时不翻译,也不用 Ling 额度")) {
Segments(options: subtitleOptions, value: settings.subtitles) { model.setSubtitles($0) }
}
- SettingsRow(title: "翻译成", detail: targetDetail, divider: false) {
- PillMenu(value: settings.target == "system" ? "跟随系统(\(targetName(model.listen.resolvedTarget)))"
+ SettingsRow(title: L("翻译成"), detail: targetDetail, divider: false) {
+ PillMenu(value: settings.target == "system" ? L("跟随系统(\(targetName(model.listen.resolvedTarget)))")
: targetName(settings.target),
- options: [("system", "跟随系统")] + targetLanguages.map { ($0.code, $0.name) }) {
+ options: [("system", L("跟随系统"))] + targetLanguages.map { ($0.code, $0.name) }) {
model.targetSelection = $0
}
}
}
- group("纪要") {
- SettingsRow(title: "纪要语言", detail: "实时纪要和完整版同一种语言", divider: false) {
- Segments(options: [("mine", "我的语言 · \(targetName(settings.myLanguage))"), ("source", sourceTitle)],
+ group(L("纪要")) {
+ SettingsRow(title: L("纪要语言"), detail: L("实时纪要和完整版同一种语言"), divider: false) {
+ Segments(options: [("mine", L("我的语言 · \(targetName(settings.myLanguage))")), ("source", sourceTitle)],
value: settings.notesLanguage) { model.setNotesLanguage($0) }
}
}
- group("同声传译") {
- SettingsRow(title: "我说", detail: settings.speakEnabled ? nil : "同声传译还没打开") {
+ group(L("同声传译")) {
+ SettingsRow(title: L("我说"), detail: settings.speakEnabled ? nil : L("同声传译还没打开")) {
PillMenu(value: settings.speakFromLang.name, options: sourceLanguages.map { ($0.locale, $0.name) }) {
settings.speakFrom = $0
model.speakFromChanged()
}
}
- SettingsRow(title: "对方听到", detail: "跟随对方时,对方说什么语言就翻成什么", divider: false) {
- PillMenu(value: settings.speakTo == "room" ? "跟随对方(\(targetName(model.speak.targetCode)))" : targetName(settings.speakTo),
- options: [("room", "跟随对方")] + targetLanguages.map { ($0.code, $0.name) }) {
+ SettingsRow(title: L("对方听到"), detail: L("跟随对方时,对方说什么语言就翻成什么"), divider: false) {
+ PillMenu(value: settings.speakTo == "room" ? L("跟随对方(\(targetName(model.speak.targetCode)))") : targetName(settings.speakTo),
+ options: [("room", L("跟随对方"))] + targetLanguages.map { ($0.code, $0.name) }) {
settings.speakTo = $0
model.objectWillChange.send()
}
@@ -56,18 +56,19 @@ struct LanguageSettings: View {
/// 对方说 English → 字幕 简体中文 · 纪要 简体中文 / 你说 中文 → 对方听到 English
private var route: some View {
VStack(alignment: .leading, spacing: 10) {
- HStack(spacing: 8) {
- label("对方说")
- chip(heardNow, accent: false)
- arrow
- Text("字幕").font(.system(size: 13)).foregroundStyle(.white)
- chip(settings.subtitles == "original" ? "原文" : targetName(model.listen.resolvedTarget), accent: true)
- Text("·").foregroundStyle(Color(white: 0.55))
- Text("纪要").font(.system(size: 13)).foregroundStyle(.white)
- chip(notesNow, accent: true)
+ // English runs wider than the card: the notes get a line of their own.
+ if uiIsChinese {
+ HStack(spacing: 8) {
+ heardRoute
+ Text("·").foregroundStyle(Color(white: 0.55))
+ notesRoute
+ }
+ } else {
+ HStack(spacing: 8) { heardRoute }
+ HStack(spacing: 8) { label(""); notesRoute }
}
HStack(spacing: 8) {
- label("你说")
+ label(L("你说"))
chip(settings.speakFromLang.name, accent: false)
arrow
Text("对方听到").font(.system(size: 13)).foregroundStyle(.white)
@@ -83,8 +84,21 @@ struct LanguageSettings: View {
.accessibilityElement(children: .combine)
}
+ @ViewBuilder private var heardRoute: some View {
+ label(L("对方说"))
+ chip(heardNow, accent: false)
+ arrow
+ Text("字幕").font(.system(size: 13)).foregroundStyle(.white)
+ chip(settings.subtitles == "original" ? L("原文") : targetName(model.listen.resolvedTarget), accent: true)
+ }
+
+ @ViewBuilder private var notesRoute: some View {
+ Text("纪要").font(.system(size: 13)).foregroundStyle(.white)
+ chip(notesNow, accent: true)
+ }
+
private func label(_ t: String) -> some View {
- Text(t).font(.system(size: 13)).foregroundStyle(Color(white: 0.72)).frame(width: 46, alignment: .leading)
+ Text(t).font(.system(size: 13)).foregroundStyle(Color(white: 0.72)).frame(width: uiIsChinese ? 46 : 64, alignment: .leading)
}
private func chip(_ t: String, accent: Bool) -> some View {
@@ -108,29 +122,29 @@ struct LanguageSettings: View {
private var heardValue: String {
if case .fixed(let l) = settings.sourceMode { return l.name }
- return "自动识别"
+ return L("自动识别")
}
private var heardNow: String {
if case .fixed(let l) = settings.sourceMode { return l.name }
- return model.listen.activeLang?.name ?? "自动识别"
+ return model.listen.activeLang?.name ?? L("自动识别")
}
private var heardDetail: String {
- if case .fixed = settings.sourceMode { return "只按这种语言识别" }
- return model.listen.activeLang.map { "现在听出是 \($0.name)" } ?? "从已安装的语音模型里挑最有把握的"
+ if case .fixed = settings.sourceMode { return L("只按这种语言识别") }
+ return model.listen.activeLang.map { L("现在听出是 \($0.name)") } ?? L("从已安装的语音模型里挑最有把握的")
}
private var targetDetail: String {
- settings.target == "system" ? "对方说的正是系统语言时,翻成系统里的另一种" : "对方说的就是这种语言时不翻译"
+ settings.target == "system" ? L("对方说的正是系统语言时,翻成系统里的另一种") : L("对方说的就是这种语言时不翻译")
}
private var sourceTitle: String {
- model.listen.activeLang.map { "会议原文 · \($0.name)" } ?? "会议原文"
+ model.listen.activeLang.map { L("会议原文 · \($0.name)") } ?? L("会议原文")
}
private var notesNow: String {
- if settings.notesLanguage == "source" { return model.listen.activeLang?.name ?? "会议原文" }
+ if settings.notesLanguage == "source" { return model.listen.activeLang?.name ?? L("会议原文") }
return targetName(settings.myLanguage)
}
}
diff --git a/Sources/LiveSubs/Ling.swift b/Sources/LiveSubs/Ling.swift
index cec35b9..1f21ff8 100644
--- a/Sources/LiveSubs/Ling.swift
+++ b/Sources/LiveSubs/Ling.swift
@@ -190,7 +190,7 @@ final class LingClient: ObservableObject {
} catch Failure.rateLimited {
keyState = .ok(seconds: Date().timeIntervalSince(started))
} catch {
- keyState = .unreachable("连不上 Ling,检查网络或代理")
+ keyState = .unreachable(L("连不上 Ling,检查网络或代理"))
}
debugLog("ling: key check → \(keyState)")
}
diff --git a/Sources/LiveSubs/ListenEngine.swift b/Sources/LiveSubs/ListenEngine.swift
index 930fda3..34f2acb 100644
--- a/Sources/LiveSubs/ListenEngine.swift
+++ b/Sources/LiveSubs/ListenEngine.swift
@@ -28,7 +28,7 @@ final class ListenEngine {
let router = AudioRouter()
private(set) var isRunning = false
- private(set) var statusText = "准备就绪"
+ private(set) var statusText = L("准备就绪")
private(set) var activeLang: Lang?
private(set) var languageConfirmed = false
private(set) var detecting = false
@@ -44,6 +44,10 @@ final class ListenEngine {
private var nextPeriodicDetection = 30.0
private var lastDetectionAt = Date.distantPast
private var ambiguousDetections = 0
+ /// Sentences finished before detection settled the language: recorded once it confirms the
+ /// language they were heard in, dropped on a switch (the replay into the new model redoes them).
+ private var unconfirmed: [(seg: Segment, at: Date, duration: Double)] = []
+ private var recordable: Bool { settings.sourceMode != .auto || languageConfirmed || ambiguousDetections >= 2 }
private var failureStreak = 0
private var segments: [Segment] = []
@@ -69,8 +73,8 @@ final class ListenEngine {
case .fixed(let lang):
return "\(lang.name) → \(target)"
case .auto:
- guard let lang = activeLang else { return "自动识别 → \(target)" }
- if detecting || !languageConfirmed { return "\(lang.name)(识别中…)→ \(target)" }
+ guard let lang = activeLang else { return L("自动识别 → \(target)") }
+ if detecting || !languageConfirmed { return L("\(lang.name)(识别中…)→ \(target)") }
return "\(lang.name) → \(target)"
}
}
@@ -96,7 +100,7 @@ final class ListenEngine {
func start() {
guard !isRunning else { return }
guard SpeechTranscriber.isAvailable else {
- setStatus("此 Mac 不支持本机语音识别")
+ setStatus(L("此 Mac 不支持本机语音识别"))
return
}
languageConfirmed = false
@@ -104,6 +108,7 @@ final class ListenEngine {
needsDetection = true
nextPeriodicDetection = 30
ambiguousDetections = 0
+ unconfirmed = []
lastDetectionAt = .distantPast
debugLog("listen start mode=\(settings.sourceMode) target=\(resolvedTarget)")
@@ -119,7 +124,7 @@ final class ListenEngine {
let last = UserDefaults.standard.string(forKey: "lastDetected")
initial = candidates.first(where: { $0.locale == last }) ?? candidates.first ?? sourceLanguages[0]
}
- setStatus("正在听")
+ setStatus(L("正在听"))
Task { await switchTranscriber(to: initial) }
}
@@ -143,7 +148,7 @@ final class ListenEngine {
lastVolatileSent = ""
volatileInFlight = false
detecting = false
- setStatus("已暂停")
+ setStatus(L("已暂停"))
}
func reconnectAudio() {
@@ -153,7 +158,7 @@ final class ListenEngine {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { [weak self] in
MainActor.assumeIsolated {
guard let self, self.isRunning else { return }
- if self.startTap() { self.setStatus("正在听") }
+ if self.startTap() { self.setStatus(L("正在听")) }
}
}
}
@@ -171,7 +176,7 @@ final class ListenEngine {
} catch {
debugLog("audio tap start failed: \(error)")
isRunning = false
- setStatus("无法读取系统音频,请在系统设置里允许“系统音频录制”")
+ setStatus(L("无法读取系统音频,请在系统设置里允许“系统音频录制”"))
return false
}
}
@@ -183,6 +188,8 @@ final class ListenEngine {
pendingSwitch = nil
needsDetection = true
if isRunning, case .fixed(let lang) = settings.sourceMode {
+ // Chosen by hand: what was held back in that language is now confirmed.
+ if lang == activeLang { flushUnconfirmed() }
Task { await switchTranscriber(to: lang) }
}
onStateChange?()
@@ -211,10 +218,10 @@ final class ListenEngine {
debugLog("model status for \(lang.locale): \(status)")
guard status != .unsupported else {
throw NSError(domain: "LiveSubsSpeech", code: 1,
- userInfo: [NSLocalizedDescriptionKey: "本机不支持\(lang.name)识别"])
+ userInfo: [NSLocalizedDescriptionKey: L("本机不支持\(lang.name)识别")])
}
if let request = try await AssetInventory.assetInstallationRequest(supporting: [transcriber]) {
- setStatus("正在下载 \(lang.name) 语音模型…")
+ setStatus(L("正在下载 \(lang.name) 语音模型…"))
try await request.downloadAndInstall()
await refreshInstalledLocales()
}
@@ -234,6 +241,7 @@ final class ListenEngine {
if activeLang != lang {
segments.removeAll()
+ unconfirmed = []
}
activeLang = lang
volatileText = ""
@@ -271,7 +279,7 @@ final class ListenEngine {
}
try await analyzer.start(inputSequence: stream)
debugLog("transcriber started locale=\(lang.locale) format=\(format)")
- setStatus("正在听")
+ setStatus(L("正在听"))
} catch {
debugLog("transcriber start failed locale=\(lang.locale): \(error)")
recognitionFailed(error, generation: gen)
@@ -283,7 +291,7 @@ final class ListenEngine {
debugLog("recognition error: \(error)")
failureStreak += 1
let delay = min(30.0, 2.0 * pow(2.0, Double(failureStreak - 1)))
- setStatus("识别出错,\(Int(delay)) 秒后重试")
+ setStatus(L("识别出错,\(Int(delay)) 秒后重试"))
guard let lang = activeLang else { return }
DispatchQueue.main.asyncAfter(deadline: .now() + delay) { [weak self] in
MainActor.assumeIsolated {
@@ -324,9 +332,12 @@ final class ListenEngine {
lastVolatileSent = ""
contentLog(String(format: "FINAL conf=%.2f [%@] %@", conf, activeLang?.locale ?? "?", text))
let duration = max(0, CMTimeGetSeconds(result.range.duration))
- // Only confirmed-language sentences go into the meeting record.
- if settings.sourceMode != .auto || languageConfirmed {
- onFinal?(seg, duration.isFinite ? duration : 0)
+ // Only confirmed-language sentences go into the meeting record; earlier ones wait.
+ let spoken = duration.isFinite ? duration : 0
+ if recordable {
+ onFinal?(seg, spoken)
+ } else {
+ unconfirmed.append((seg, Date(), spoken))
}
translateSegment(id: seg.id)
if settings.sourceMode == .auto, conf < 0.6, text.count >= 4 {
@@ -344,7 +355,7 @@ final class ListenEngine {
let source = [segments.last?.text ?? "", volatileText].filter { !$0.isEmpty }
.joined(separator: srcJoin.isEmpty ? " " : srcJoin)
if settings.sourceMode == .auto, !languageConfirmed, ambiguousDetections < 2 {
- onSubtitle?(source, "正在识别语言…")
+ onSubtitle?(source, L("正在识别语言…"))
return
}
let tgtJoin = joiner(for: resolvedTarget)
@@ -393,11 +404,13 @@ final class ListenEngine {
debugLog("detect: ambiguous, keeping \(activeLang?.locale ?? "-")")
ambiguousDetections += 1
if !languageConfirmed { needsDetection = true }
+ if recordable { flushUnconfirmed() }
renderSubtitles()
return
}
if best.lang == activeLang {
languageConfirmed = true
+ flushUnconfirmed()
pendingSwitch = nil
UserDefaults.standard.set(best.lang.locale, forKey: "lastDetected")
renderSubtitles()
@@ -408,6 +421,7 @@ final class ListenEngine {
if !languageConfirmed || overwhelming || pendingSwitch == best.lang {
debugLog("detect: switching \(activeLang?.locale ?? "-") → \(best.lang.locale)")
languageConfirmed = true
+ unconfirmed = []
pendingSwitch = nil
UserDefaults.standard.set(best.lang.locale, forKey: "lastDetected")
Task { await switchTranscriber(to: best.lang, replaySeconds: 8) }
@@ -417,6 +431,18 @@ final class ListenEngine {
}
}
+ /// Records the sentences held back before the language was confirmed, with the translation
+ /// they got meanwhile and their time of speaking.
+ private func flushUnconfirmed() {
+ let held = unconfirmed
+ unconfirmed = []
+ for h in held {
+ var seg = h.seg
+ if let now = segments.first(where: { $0.id == seg.id }) { seg.translation = now.translation }
+ onFinal?(seg, h.duration + Date().timeIntervalSince(h.at))
+ }
+ }
+
// MARK: Translation
private func startTickTimer() {
@@ -442,7 +468,7 @@ final class ListenEngine {
if source == target { return text }
let out = await translator?.translate(text, source: source, target: target, kind: kind, trace: trace)
if out == nil, segments.allSatisfy({ $0.translation == nil }) && volatileTranslation.isEmpty {
- onSubtitle?(volatileText.isEmpty ? (segments.last?.text ?? "") : volatileText, "翻译暂不可用")
+ onSubtitle?(volatileText.isEmpty ? (segments.last?.text ?? "") : volatileText, L("翻译暂不可用"))
}
return out
}
diff --git a/Sources/LiveSubs/Localization.swift b/Sources/LiveSubs/Localization.swift
new file mode 100644
index 0000000..2970251
--- /dev/null
+++ b/Sources/LiveSubs/Localization.swift
@@ -0,0 +1,20 @@
+import Foundation
+
+/// UI text: the Chinese source is the key, `en.lproj/Localizable.strings` holds the English.
+/// Interpolations become format keys ("已听到 %lld 句"); `-emit-localized-strings` lists every key
+/// (scripts/check-strings.sh checks the English table against it).
+func L(_ value: String.LocalizationValue) -> String { String(localized: value) }
+
+/// The locale the UI is shown in (dates in titles and exports follow it, not the region setting).
+var uiLocale: Locale { Locale(identifier: Bundle.main.preferredLocalizations.first ?? "zh-Hans") }
+
+/// True when the UI is Chinese.
+var uiIsChinese: Bool { (Bundle.main.preferredLocalizations.first ?? "zh").hasPrefix("zh") }
+
+/// A date in the UI language from a template ("MMMd" → "11月1日" / "Nov 1").
+func dateText(_ date: Date, _ template: String) -> String {
+ let f = DateFormatter()
+ f.locale = uiLocale
+ f.setLocalizedDateFormatFromTemplate(template)
+ return f.string(from: date)
+}
diff --git a/Sources/LiveSubs/Notes.swift b/Sources/LiveSubs/Notes.swift
index 7cebdb1..5ad6932 100644
--- a/Sources/LiveSubs/Notes.swift
+++ b/Sources/LiveSubs/Notes.swift
@@ -102,6 +102,8 @@ final class NotesEngine: ObservableObject {
private var inFlight = false
/// A final pass asked for while another call was running; it runs right after.
private var pendingFinal: String?
+ /// A language change that arrived while another update was running: rewrite after it.
+ private var pendingRewrite: String?
private var lastAttempt = Date.distantPast
private var freshGeneration = 0
static let interval: TimeInterval = 45
@@ -182,6 +184,8 @@ final class NotesEngine: ObservableObject {
// A key was added or replaced since the last failure.
if (state == .noKey || state == .invalidKey), ling.usable, ling.keyState != .checking { state = .idle }
if state == .idle, !ling.hasKey { state = .noKey }
+ // A key that was just checked and refused says so, rather than asking for a key again.
+ if state == .noKey || state == .idle, ling.hasKey, ling.keyState == .invalid { state = .invalidKey }
guard let id = sessionID, !inFlight else { return }
guard let s = store.session(id), s.lines.count > notes.covered else { return }
// First notes as soon as there is something to say, then every 45 s.
@@ -195,6 +199,7 @@ final class NotesEngine: ObservableObject {
if inFlight {
// Never drop the end-of-meeting pass or a "生成纪要" request: queue it.
if final { pendingFinal = id; generatingID = id }
+ if fresh { pendingRewrite = id }
return
}
guard let session = store.session(id), !session.lines.isEmpty else { return }
@@ -208,7 +213,11 @@ final class NotesEngine: ObservableObject {
if final, generatingID == id { generatingID = nil }
if let next = pendingFinal {
pendingFinal = nil
+ pendingRewrite = nil // the final pass starts from nothing anyway
Task { await update(next, final: true) }
+ } else if let next = pendingRewrite {
+ pendingRewrite = nil
+ Task { await update(next, final: false, fresh: true) }
}
}
@@ -235,6 +244,12 @@ final class NotesEngine: ObservableObject {
state = .failed
return
}
+ // The notes language changed while this was running: the queued rewrite replaces it.
+ guard language(id) == lang else {
+ debugLog("notes: language changed during the update, reply dropped")
+ state = .idle
+ return
+ }
Self.carryTimes(from: base, into: &next)
// A reply without a name keeps the last one (not after a language change).
if next.title == nil, !fresh { next.title = (id == shownID ? notes : session.notes)?.title }
@@ -281,12 +296,14 @@ final class NotesEngine: ObservableObject {
var known: [String: Double] = [:]
for t in old.topics { for (i, p) in t.points.enumerated() { if let x = t.pointTime(i) { known[p] = x } } }
for (ti, t) in new.topics.enumerated() {
- let times = t.points.enumerated().map { i, p in t.pointTime(i) ?? known[p] }
+ // A point keeps the time it was first heard: a later mention never moves it later.
+ let times = t.points.enumerated().map { i, p in [t.pointTime(i), known[p]].compactMap { $0 }.min() }
new.topics[ti].pointTimes = times.contains { $0 != nil } ? times : nil
}
let items = Dictionary((old.conclusions + old.todos).compactMap { i in i.t.map { (i.text, $0) } }, uniquingKeysWith: { a, _ in a })
- for i in new.conclusions.indices where new.conclusions[i].t == nil { new.conclusions[i].t = items[new.conclusions[i].text] }
- for i in new.todos.indices where new.todos[i].t == nil { new.todos[i].t = items[new.todos[i].text] }
+ func earliest(_ a: Double?, _ b: Double?) -> Double? { [a, b].compactMap { $0 }.min() }
+ for i in new.conclusions.indices { new.conclusions[i].t = earliest(new.conclusions[i].t, items[new.conclusions[i].text]) }
+ for i in new.todos.indices { new.todos[i].t = earliest(new.todos[i].t, items[new.todos[i].text]) }
}
// MARK: Prompt
diff --git a/Sources/LiveSubs/NotesViews.swift b/Sources/LiveSubs/NotesViews.swift
index e3bb47c..3ff25dc 100644
--- a/Sources/LiveSubs/NotesViews.swift
+++ b/Sources/LiveSubs/NotesViews.swift
@@ -32,10 +32,10 @@ struct NotesContentView: View {
VStack(alignment: .leading, spacing: 8) {
HStack(spacing: 8) {
Text("总结").font(.system(size: 15, weight: .bold))
- if summaryJustChanged { Tag("刚更新", live: true) }
+ if summaryJustChanged { Tag(L("刚更新"), live: true) }
Spacer()
- if notes.final { Tag("完整版") } else if live {
- Tag(coveredUntil.map { "速记版 · 到 \(NotesEngine.clock($0))" } ?? "速记版")
+ if notes.final { Tag(L("完整版")) } else if live {
+ Tag(coveredUntil.map { L("速记版 · 到 \(NotesEngine.clock($0))") } ?? L("速记版"))
}
}
Text(notes.summary).font(.system(size: 14)).lineSpacing(4).textSelection(.enabled)
@@ -47,7 +47,7 @@ struct NotesContentView: View {
if !notes.topics.isEmpty {
VStack(alignment: .leading, spacing: document ? 0 : 14) {
- title("议题")
+ title(L("议题"))
ForEach(Array(notes.topics.enumerated()), id: \.element.id) { i, topic in
if document { Divider() }
TopicView(topic: topic,
@@ -61,7 +61,7 @@ struct NotesContentView: View {
if !notes.conclusions.isEmpty || !notes.todos.isEmpty {
VStack(alignment: .leading, spacing: 10) {
- title(notes.todos.isEmpty ? "结论" : "结论和待办")
+ title(notes.todos.isEmpty ? L("结论") : L("结论和待办"))
if document {
VStack(alignment: .leading, spacing: 0) { items }
} else {
@@ -72,11 +72,11 @@ struct NotesContentView: View {
if !notes.terms.isEmpty {
VStack(alignment: .leading, spacing: 10) {
- title("人名和术语")
+ title(L("人名和术语"))
FlowLayout(spacing: 6) {
ForEach(notes.terms) { t in
(Text(t.name).bold() + Text(t.note.isEmpty ? "" : " \(t.note)")
- + Text(t.heard.isEmpty ? "" : " · 原识别 \(t.heard.prefix(2).joined(separator: "、"))")
+ + Text(t.heard.isEmpty ? "" : L(" · 原识别 \(t.heard.prefix(2).joined(separator: "、"))"))
.foregroundColor(Palette.tertiary))
.font(.system(size: 12))
.padding(.horizontal, 9).padding(.vertical, 5)
@@ -116,11 +116,11 @@ struct NotesContentView: View {
.foregroundStyle(item.support == 0 ? Palette.tertiary : Palette.ink)
.frame(maxWidth: .infinity, alignment: .leading)
if item.support == 0 {
- Tag("依据较少")
+ Tag(L("依据较少"))
} else if let t = item.t {
- TimeLink(text: "\(NotesEngine.clock(t)) · \(item.support) 句", t: t, onJump: onJump)
+ TimeLink(text: L("\(NotesEngine.clock(t)) · \(item.support) 句"), t: t, onJump: onJump)
} else {
- Tag("依据 \(item.support) 句")
+ Tag(L("依据 \(item.support) 句"))
}
}
.padding(.horizontal, document ? 0 : 16).padding(.vertical, 11)
@@ -149,8 +149,8 @@ private struct TopicView: View {
}
.buttonStyle(.plain).help("看原话")
Text(topic.title).font(.system(size: 15, weight: .bold))
- if current { Tag("正在讲", live: true) }
- if fresh.contains(topic.title) && !current { Tag("新", live: true) }
+ if current { Tag(L("正在讲"), live: true) }
+ if fresh.contains(topic.title) && !current { Tag(L("新"), live: true) }
}
VStack(alignment: .leading, spacing: 6) {
if !topic.summary.isEmpty {
@@ -163,7 +163,7 @@ private struct TopicView: View {
.alignmentGuide(.firstTextBaseline) { $0[.bottom] + 4 }
Text(p).font(.system(size: 14)).lineSpacing(2).textSelection(.enabled)
.fixedSize(horizontal: false, vertical: true)
- if fresh.contains(p) { Tag("新", live: true) }
+ if fresh.contains(p) { Tag(L("新"), live: true) }
Spacer(minLength: 4)
if let t = topic.pointTime(i) { TimeLink(text: NotesEngine.clock(t), t: t, onJump: onJump) }
}
@@ -187,7 +187,7 @@ private struct TopicView: View {
/// "01:04–02:02", or "02:03 起" for the topic being discussed.
private var range: String {
let from = NotesEngine.clock(topic.start)
- guard let end, end > topic.start + 1 else { return current ? "\(from) 起" : from }
+ guard let end, end > topic.start + 1 else { return current ? L("\(from) 起") : from }
return "\(from)–\(NotesEngine.clock(end))"
}
@@ -225,7 +225,7 @@ struct FishboneView: View {
VStack(alignment: .leading, spacing: 10) {
HStack(spacing: 6) {
Image(systemName: "point.3.connected.trianglepath.dotted").font(.system(size: 12)).foregroundStyle(Palette.secondary)
- Text(fishbone.question.isEmpty ? "为什么" : fishbone.question).font(.system(size: 13, weight: .bold))
+ Text(fishbone.question.isEmpty ? L("为什么") : fishbone.question).font(.system(size: 13, weight: .bold))
Spacer()
Text("鱼骨图").font(.system(size: 11)).foregroundStyle(Palette.tertiary)
}
@@ -276,7 +276,7 @@ struct FishboneView: View {
.contentShape(Rectangle())
}
.buttonStyle(.plain)
- .help(weak ? "依据较少,仅供参考" : "看原话")
+ .help(weak ? L("依据较少,仅供参考") : L("看原话"))
}
}
diff --git a/Sources/LiveSubs/NotesWindow.swift b/Sources/LiveSubs/NotesWindow.swift
index 4636ad0..9b27eb5 100644
--- a/Sources/LiveSubs/NotesWindow.swift
+++ b/Sources/LiveSubs/NotesWindow.swift
@@ -78,6 +78,12 @@ final class NotesWindowController: NSObject, NSWindowDelegate {
panel?.orderOut(nil)
}
+ /// Closed with its close button (hide() doesn't come here): the meeting goes on in the
+ /// records window, so the notes stay one click away.
+ func windowWillClose(_ notification: Notification) {
+ model?.notesWindowClosed()
+ }
+
var frame: NSRect? { panel?.frame }
/// Card ⇄ sidebar ⇄ wide, keeping the window's top-right corner where it is.
@@ -94,6 +100,9 @@ final class NotesWindowController: NSObject, NSWindowDelegate {
func place(_ r: NSRect) { panel?.setFrame(r, display: true) }
+ /// Debug control only: what the close button does.
+ func performClose() { panel?.performClose(nil) }
+
/// Debug control only: let screenshots capture the window.
func setCapturable(_ on: Bool) { panel?.sharingType = on ? .readOnly : .none }
@@ -221,10 +230,12 @@ struct NotesWindowView: View {
VStack(alignment: .leading, spacing: 16) {
HStack(alignment: .top, spacing: 4) {
VStack(alignment: .leading, spacing: 6) {
- Text(live || session == nil ? "实时纪要" : "会议纪要").font(.system(size: 24, weight: .bold))
+ Text(live || session == nil ? L("实时纪要") : L("会议纪要")).font(.system(size: 24, weight: .bold))
HStack(spacing: 6) {
if live { LiveDot() }
- Text(statusLine).font(.system(size: 12)).foregroundStyle(Palette.tertiary).lineLimit(1)
+ // Wraps rather than cut off "· 纪要已更新至 …" when the buttons leave little room.
+ Text(statusLine).font(.system(size: 12)).foregroundStyle(Palette.tertiary).lineLimit(2)
+ .fixedSize(horizontal: false, vertical: true)
}
}
Spacer()
@@ -241,15 +252,15 @@ struct NotesWindowView: View {
}
.buttonStyle(.plain).help("结束这场会议").padding(.trailing, 4)
}
- iconButton(wide ? "rectangle.split.2x1.fill" : "rectangle.split.2x1", help: wide ? "收窄" : "纪要和原话并排") {
+ iconButton(wide ? "rectangle.split.2x1.fill" : "rectangle.split.2x1", help: wide ? L("收窄") : L("纪要和原话并排")) {
setWidth(wide ? 460 : 820, nil)
}
- iconButton("minus", help: "收成小卡") { collapse() }
+ iconButton("minus", help: L("收成小卡")) { collapse() }
}
if !wide {
HStack(spacing: 0) {
- segment("纪要", "notes")
- segment(engine.notes.isEmpty && heard > 0 ? "文字记录 · \(heard)" : "文字记录", "transcript")
+ segment(L("纪要"), "notes")
+ segment(engine.notes.isEmpty && heard > 0 ? L("文字记录 · \(heard)") : L("文字记录"), "transcript")
}
.padding(4)
.background(RoundedRectangle(cornerRadius: 12).fill(Palette.fill))
@@ -269,11 +280,11 @@ struct NotesWindowView: View {
.onSubmit { step(1) }
.onChange(of: query) { _, _ in matchIndex = 0 }
if !query.isEmpty {
- Text(matches.isEmpty ? "无结果" : "\(currentIndex + 1) / \(matches.count)")
+ Text(matches.isEmpty ? L("无结果") : "\(currentIndex + 1) / \(matches.count)")
.font(.system(size: 12).monospacedDigit()).foregroundStyle(Palette.tertiary)
- iconButton("chevron.up", help: "上一个") { step(-1) }.disabled(matches.isEmpty)
- iconButton("chevron.down", help: "下一个") { step(1) }.disabled(matches.isEmpty)
- iconButton("xmark", help: "清除") { query = "" }
+ iconButton("chevron.up", help: L("上一个")) { step(-1) }.disabled(matches.isEmpty)
+ iconButton("chevron.down", help: L("下一个")) { step(1) }.disabled(matches.isEmpty)
+ iconButton("xmark", help: L("清除")) { query = "" }
}
}
.padding(.leading, 12).padding(.trailing, 2).frame(height: 34)
@@ -334,15 +345,15 @@ struct NotesWindowView: View {
private var statusLine: String {
if live {
- var parts = [(heard == 0 ? "正在听 · " : "正在记录 · ") + NotesEngine.clock(elapsed)]
- if heard > 0 { parts.append("\(heard) 句") }
- if !engine.notes.isEmpty, lastCovered > 0 { parts.append("纪要已更新至 \(NotesEngine.clock(lastCovered))") }
+ var parts = [(heard == 0 ? L("正在听 · ") : L("正在记录 · ")) + NotesEngine.clock(elapsed)]
+ if heard > 0 { parts.append(L("\(heard) 句")) }
+ if !engine.notes.isEmpty, lastCovered > 0 { parts.append(L("纪要已更新至 \(NotesEngine.clock(lastCovered))")) }
return parts.joined(separator: " · ")
}
- let clock = session.map { "已结束 · " + TranscriptExport.header($0) } ?? "没有在记录"
+ let clock = session.map { L("已结束 · ") + TranscriptExport.header($0) } ?? L("没有在记录")
guard let at = engine.notes.updatedAt, engine.state != .updating else { return clock }
let ago = Int(now.timeIntervalSince(at))
- return clock + " · " + (ago < 10 ? "刚刚更新" : ago < 60 ? "\(ago) 秒前更新" : "\(ago / 60) 分钟前更新")
+ return clock + " · " + (ago < 10 ? L("刚刚更新") : ago < 60 ? L("\(ago) 秒前更新") : L("\(ago / 60) 分钟前更新"))
}
// MARK: This meeting's languages
@@ -352,7 +363,7 @@ struct NotesWindowView: View {
/// an inactive app closes as soon as it opens); the defaults live in 设置 › 语言.
private var languageChip: some View {
let id = session?.id ?? ""
- let from = model.meetingLanguage(store.liveID).map(Self.short) ?? "自动"
+ let from = model.meetingLanguage(store.liveID).map(Self.short) ?? L("自动")
return Button { languageOpen.toggle() } label: {
HStack(spacing: 4) {
Text(from)
@@ -364,7 +375,7 @@ struct NotesWindowView: View {
.background(RoundedRectangle(cornerRadius: 7).fill(Palette.accentPale))
.contentShape(Rectangle())
}
- .buttonStyle(.plain).help("这场会议的语言").accessibilityLabel("这场会议的语言")
+ .buttonStyle(.plain).help("这场会议的语言").accessibilityLabel(L("这场会议的语言"))
}
private func languageCard(_ id: String) -> some View {
@@ -377,20 +388,20 @@ struct NotesWindowView: View {
Text("只改这一场,默认值在 设置 › 语言").font(.system(size: 12)).foregroundStyle(Palette.tertiary)
}
Spacer()
- iconButton("xmark", help: "收起") { languageOpen = false }
+ iconButton("xmark", help: L("收起")) { languageOpen = false }
}
VStack(alignment: .leading, spacing: 6) {
Text("对方说").font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.secondary)
- Text(source.map(targetName) ?? "还没听出来").font(.system(size: 13))
+ Text(source.map(targetName) ?? L("还没听出来")).font(.system(size: 13))
}
VStack(alignment: .leading, spacing: 6) {
Text("字幕").font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.secondary)
- Segments(options: [("both", "双语"), ("translation", "只看译文"), ("original", "只看原文")],
+ Segments(options: [("both", L("双语")), ("translation", L("只看译文")), ("original", L("只看原文"))],
value: model.subtitles, fill: true) { model.setSubtitles($0, meetingOnly: true) }
}
VStack(alignment: .leading, spacing: 6) {
Text("纪要").font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.secondary)
- Segments(options: [("mine", targetName(mine)), ("source", source.map { "\(targetName($0))(原文)" } ?? "会议原文")],
+ Segments(options: [("mine", targetName(mine)), ("source", source.map { L("\(targetName($0))(原文)") } ?? L("会议原文"))],
value: model.notesChoice(id), fill: true) { model.setNotesLanguage($0, meetingOnly: true) }
Text("换了以后会马上用新语言重写纪要").font(.system(size: 12)).foregroundStyle(Palette.tertiary)
}
@@ -408,10 +419,10 @@ struct NotesWindowView: View {
static func short(_ code: String) -> String {
switch code {
- case "zh-CN": "中"
- case "zh-TW": "繁"
- case "ja": "日"
- case "ko": "韩"
+ case "zh-CN": L("中")
+ case "zh-TW": L("繁")
+ case "ja": L("日")
+ case "ko": L("韩")
default: code.prefix(2).uppercased()
}
}
@@ -436,8 +447,8 @@ struct NotesWindowView: View {
.font(.system(size: 12)).foregroundStyle(Palette.secondary).lineSpacing(2)
.fixedSize(horizontal: false, vertical: true)
HStack(spacing: 8) {
- SoftButton("继续记录") { confirmEnd = false }
- SoftButton("结束会议", dark: true) {
+ SoftButton(L("继续记录")) { confirmEnd = false }
+ SoftButton(L("结束会议"), dark: true) {
confirmEnd = false
model.stop()
}
@@ -460,17 +471,17 @@ struct NotesWindowView: View {
}
HStack(spacing: 8) {
if let id = session?.id, let other = otherNotesLanguage(id) {
- SoftButton("改用\(targetName(other.code))重新整理") { model.regenerateNotes(id, choice: other.choice) }
+ SoftButton(L("改用\(targetName(other.code))重新整理")) { model.regenerateNotes(id, choice: other.choice) }
.disabled(engine.state == .updating)
}
if let id = session?.id {
- SoftButton("在会议记录中查看") {
+ SoftButton(L("在会议记录中查看")) {
model.mainShow = nil
model.mainShow = "\(id),notes"
model.openMainWindow?()
}
}
- SoftButton(session == nil ? "开始记录" : "开始新会议", dark: true) { model.start() }
+ SoftButton(session == nil ? L("开始记录") : L("开始新会议"), dark: true) { model.start() }
}
}
.frame(maxWidth: .infinity, alignment: .leading)
@@ -486,10 +497,10 @@ struct NotesWindowView: View {
}
private var endedText: String {
- guard session != nil else { return "现在没有在记录" }
- if engine.state == .updating { return "会议已结束,正在整理完整版纪要…" }
- if engine.state == .noKey || engine.notes.isEmpty { return "会议已结束,文字记录已保存" }
- return "会议已结束,完整版纪要已整理好 · " + targetName(model.notesLanguageCode(session?.id ?? ""))
+ guard session != nil else { return L("现在没有在记录") }
+ if engine.state == .updating { return L("会议已结束,正在整理完整版纪要…") }
+ if engine.state == .noKey || engine.notes.isEmpty { return L("会议已结束,文字记录已保存") }
+ return L("会议已结束,完整版纪要已整理好 · ") + targetName(model.notesLanguageCode(session?.id ?? ""))
}
// MARK: Banners (key and service states)
@@ -500,13 +511,13 @@ struct NotesWindowView: View {
case .noKey where session?.lines.isEmpty == false || live:
keyEntry
case .invalidKey:
- notice("key 已失效(令牌被删或免费额度用尽),纪要停留在 \(NotesEngine.clock(lastCovered))。", tint: Palette.errorPale) {
- SoftButton("更换 key", dark: true) { model.openSettings(.ai) }
+ notice(L("key 已失效(令牌被删或免费额度用尽),纪要停留在 \(NotesEngine.clock(lastCovered))。"), tint: Palette.errorPale) {
+ SoftButton(L("更换 key"), dark: true) { model.openSettings(.ai) }
}
case .rateLimited:
- notice("请求过于频繁,稍后会自动重试。纪要停留在 \(NotesEngine.clock(lastCovered))。", tint: Palette.fill) { EmptyView() }
+ notice(L("请求过于频繁,稍后会自动重试。纪要停留在 \(NotesEngine.clock(lastCovered))。"), tint: Palette.fill) { EmptyView() }
case .failed:
- notice("这轮没整理好,下一轮会自动重试。", tint: Palette.fill) { EmptyView() }
+ notice(L("这轮没整理好,下一轮会自动重试。"), tint: Palette.fill) { EmptyView() }
default:
EmptyView()
}
@@ -538,7 +549,7 @@ struct NotesWindowView: View {
.background(RoundedRectangle(cornerRadius: 9).fill(Color.white))
.overlay(RoundedRectangle(cornerRadius: 9).stroke(Palette.line, lineWidth: 1))
.onSubmit(saveKey)
- SoftButton("保存并开始", dark: true, action: saveKey)
+ SoftButton(L("保存并开始"), dark: true, action: saveKey)
}
Button("获取 Ling key ↗") {
if let url = URL(string: "https://chat.ant-ling.com/open") { NSWorkspace.shared.open(url) }
@@ -582,7 +593,7 @@ struct NotesWindowView: View {
} else {
VStack {
Spacer()
- Text(session == nil ? "没有进行中的会议" : "这场会议还没有纪要")
+ Text(session == nil ? L("没有进行中的会议") : L("这场会议还没有纪要"))
.font(.system(size: 13)).foregroundStyle(Palette.tertiary)
Spacer()
Spacer()
@@ -639,11 +650,11 @@ struct NotesWindowView: View {
.font(.system(size: 12).monospacedDigit()).foregroundStyle(Palette.tertiary)
} else {
if live { LiveDot() }
- Text(currentTopic.map { (live ? "正在讲 · " : "最后一个议题 · ") + "\(NotesEngine.clock($0.start)) 起" } ?? (live ? "正在记录" : "实时纪要"))
+ Text(currentTopic.map { (live ? L("正在讲 · ") : L("最后一个议题 · ")) + L("\(NotesEngine.clock($0.start)) 起") } ?? (live ? L("正在记录") : L("实时纪要")))
.font(.system(size: 12)).foregroundStyle(Palette.tertiary)
}
Spacer()
- iconButton("arrow.up.left.and.arrow.down.right", help: "展开纪要") { setWidth(460, 760) }
+ iconButton("arrow.up.left.and.arrow.down.right", help: L("展开纪要")) { setWidth(460, 760) }
}
if catchUp {
Text("这 \(span) 讲了").font(.system(size: 17, weight: .bold))
@@ -670,8 +681,8 @@ struct NotesWindowView: View {
.frame(maxWidth: .infinity, alignment: .leading)
}
HStack(spacing: 8) {
- SoftButton("展开纪要", dark: true) { setWidth(460, 760) }
- SoftButton("看过了") {
+ SoftButton(L("展开纪要"), dark: true) { setWidth(460, 760) }
+ SoftButton(L("看过了")) {
catchUp = false
collapsedAt = elapsed
seenItems = items(before: .infinity)
@@ -679,7 +690,7 @@ struct NotesWindowView: View {
}
}
} else {
- Text(currentTopic?.title ?? (!live ? "还没有纪要" : heard == 0 ? "正在听" : "正在生成纪要…"))
+ Text(currentTopic?.title ?? (!live ? L("还没有纪要") : heard == 0 ? L("正在听") : L("正在生成纪要…")))
.font(.system(size: 17, weight: .bold)).lineLimit(2)
if addedCount.points == 0 && addedCount.topics == 0, let last = currentTopic?.points.last {
Text(last).font(.system(size: 13)).foregroundStyle(Palette.secondary).lineLimit(2)
@@ -700,7 +711,7 @@ struct NotesWindowView: View {
}
.buttonStyle(.plain)
} else if collapsedAt > 0 || live {
- Text("收起 \(span) · " + (live ? "还在讲这个" : "没有新内容"))
+ Text(L("收起 \(span) · ") + (live ? L("还在讲这个") : L("没有新内容")))
.font(.system(size: 12)).foregroundStyle(Palette.tertiary)
}
}
@@ -726,14 +737,14 @@ struct NotesWindowView: View {
private var addedLabel: String {
let c = addedCount
var parts: [String] = []
- if c.topics > 0 { parts.append("\(c.topics) 个议题") }
- if c.points > 0 { parts.append("\(c.points) 条要点") }
- return "收起后新增 " + parts.joined(separator: "、")
+ if c.topics > 0 { parts.append(L("\(c.topics) 个议题")) }
+ if c.points > 0 { parts.append(L("\(c.points) 条要点")) }
+ return L("收起后新增 ") + parts.joined(separator: uiIsChinese ? "、" : ", ")
}
private var span: String {
let s = max(0, Int(elapsed - collapsedAt))
- return s < 60 ? "\(s) 秒" : "\(s / 60) 分钟"
+ return s < 60 ? L("\(s) 秒") : L("\(s / 60) 分钟")
}
}
diff --git a/Sources/LiveSubs/Onboarding.swift b/Sources/LiveSubs/Onboarding.swift
index 7d21ed7..ca8bfd4 100644
--- a/Sources/LiveSubs/Onboarding.swift
+++ b/Sources/LiveSubs/Onboarding.swift
@@ -284,7 +284,7 @@ struct OnboardingView: View {
if step < 3 { step += 1 } else { onFinish() }
} label: {
HStack(spacing: 8) {
- Text(step < 3 ? "继续" : "开始使用")
+ Text(step < 3 ? L("继续") : L("开始使用"))
if step < 3 { Image(systemName: "arrow.right") }
}
.font(.system(size: 14, weight: .semibold)).foregroundStyle(.white)
@@ -361,17 +361,17 @@ struct OnboardingView: View {
private var permissions: some View {
VStack(alignment: .leading, spacing: 24) {
- title("先打开两个开关", "去系统设置打开,回来会自动识别。")
+ title(L("先打开两个开关"), L("去系统设置打开,回来会自动识别。"))
VStack(spacing: 0) {
- row(icon: "speaker.wave.2", title: "听电脑里的声音", tag: "必需", tagAccent: true, detail: "用于生成字幕,不会录制屏幕画面") {
- if model.systemAudioOK { done("已打开") } else { primary("去开启") { model.requestSystemAudio() } }
+ row(icon: "speaker.wave.2", title: L("听电脑里的声音"), tag: L("必需"), tagAccent: true, detail: L("用于生成字幕,不会录制屏幕画面")) {
+ if model.systemAudioOK { done(L("已打开")) } else { primary(L("去开启")) { model.requestSystemAudio() } }
}
Divider().padding(.horizontal, 22)
- row(icon: "mic", title: "麦克风", tag: "可选", detail: "仅在同声传译时使用") {
+ row(icon: "mic", title: L("麦克风"), tag: L("可选"), detail: L("仅在同声传译时使用")) {
switch model.micStatus {
- case .authorized: done("已允许")
- case .notDetermined: secondary("允许") { model.requestMicrophone() }
- default: secondary("去打开") { model.openMicrophoneSettings() }
+ case .authorized: done(L("已允许"))
+ case .notDetermined: secondary(L("允许")) { model.requestMicrophone() }
+ default: secondary(L("去打开")) { model.openMicrophoneSettings() }
}
}
}
@@ -386,7 +386,7 @@ struct OnboardingView: View {
private var tryIt: some View {
VStack(alignment: .leading, spacing: 22) {
- title("放一段视频试试", "点击播放,看看实时字幕效果。")
+ title(L("放一段视频试试"), L("点击播放,看看实时字幕效果。"))
ZStack {
PlayerSurface(player: sample.player)
if !sample.playing {
@@ -396,7 +396,7 @@ struct OnboardingView: View {
.overlay(Image(systemName: "play.fill").font(.system(size: 22)).foregroundStyle(Palette.ink).offset(x: 2))
}
.buttonStyle(.plain)
- .accessibilityLabel("播放示例视频")
+ .accessibilityLabel(L("播放示例视频"))
VStack {
Spacer()
HStack {
@@ -416,7 +416,7 @@ struct OnboardingView: View {
.frame(height: 3)
Spacer()
VStack(spacing: 4) {
- Text(model.liveSource.isEmpty ? "正在听…" : model.liveSource)
+ Text(model.liveSource.isEmpty ? L("正在听…") : model.liveSource)
.font(.system(size: 13)).foregroundStyle(.white.opacity(0.65)).lineLimit(1).truncationMode(.head)
Text(model.liveTranslation)
.font(.system(size: 19, weight: .semibold)).foregroundStyle(.white).lineLimit(2).truncationMode(.head)
@@ -434,9 +434,9 @@ struct OnboardingView: View {
.background(RoundedRectangle(cornerRadius: 18).fill(Color(red: 0.1, green: 0.11, blue: 0.13)))
HStack(spacing: 12) {
- ChoiceRow(label: "听到", value: heardName, badge: nil, options: sourceOptions) { model.sourceSelection = $0 }
- ChoiceRow(label: "翻译成", value: targetName(model.listen.resolvedTarget),
- badge: settings.target == "system" ? "跟随系统" : nil, options: targetOptions) { model.targetSelection = $0 }
+ ChoiceRow(label: L("听到"), value: heardName, badge: nil, options: sourceOptions) { model.sourceSelection = $0 }
+ ChoiceRow(label: L("翻译成"), value: targetName(model.listen.resolvedTarget),
+ badge: settings.target == "system" ? L("跟随系统") : nil, options: targetOptions) { model.targetSelection = $0 }
}
Text("字幕条可任意拖动,拖拽右下角可调整大小。").font(.system(size: 12)).foregroundStyle(Palette.secondary)
}
@@ -444,13 +444,13 @@ struct OnboardingView: View {
private var heardName: String {
if case .fixed(let l) = settings.sourceMode { return l.name }
- return model.listen.activeLang.map { "自动 · \($0.name)" } ?? "自动识别"
+ return model.listen.activeLang.map { L("自动 · \($0.name)") } ?? L("自动识别")
}
private var sourceOptions: [(id: String, title: String)] {
- [("auto", "自动识别")] + sourceLanguages.map { ($0.locale, $0.name) }
+ [("auto", L("自动识别"))] + sourceLanguages.map { ($0.locale, $0.name) }
}
private var targetOptions: [(id: String, title: String)] {
- [("system", "跟随系统")] + targetLanguages.map { ($0.code, $0.name) }
+ [("system", L("跟随系统"))] + targetLanguages.map { ($0.code, $0.name) }
}
// MARK: Step 3
@@ -458,12 +458,12 @@ struct OnboardingView: View {
private var speaking: some View {
VStack(alignment: .leading, spacing: 22) {
HStack(alignment: .top, spacing: 24) {
- title("想让对方听懂你?", "按住说\(settings.speakFromLang.name),对方听到翻译后的语音。")
+ title(L("想让对方听懂你?"), L("按住说\(settings.speakFromLang.name),对方听到翻译后的语音。"))
Spacer()
VStack(alignment: .trailing, spacing: 6) {
HStack(alignment: .bottom, spacing: 6) {
if settings.talkKey.isRightOption {
- key("⌥", "右侧 option", width: 96)
+ key("⌥", L("右侧 option"), width: 96)
} else {
ForEach(Array(settings.talkKey.keys.enumerated()), id: \.offset) {
key($0.element, "", width: $0.element.count > 2 ? 96 : 52)
diff --git a/Sources/LiveSubs/Overlay.swift b/Sources/LiveSubs/Overlay.swift
index 1fb20b9..692f5c2 100644
--- a/Sources/LiveSubs/Overlay.swift
+++ b/Sources/LiveSubs/Overlay.swift
@@ -524,9 +524,9 @@ final class OverlayView: NSView {
y -= 12 * k(fs)
let label: String
switch s.phase {
- case .listening: label = "你在说… " + s.source
- case .translating: label = "翻译中… " + s.source
- case .speaking, .idle: label = "你:" + s.source
+ case .listening: label = L("你在说… ") + s.source
+ case .translating: label = L("翻译中… ") + s.source
+ case .speaking, .idle: label = L("你:") + s.source
}
draw(label, font: srcFont(fs), color: orange.withAlphaComponent(0.8), maxLines: 1)
draw(s.translation, font: speakFont(fs), color: orange, maxLines: 2)
diff --git a/Sources/LiveSubs/SessionStore.swift b/Sources/LiveSubs/SessionStore.swift
index 1619d1d..61e7f32 100644
--- a/Sources/LiveSubs/SessionStore.swift
+++ b/Sources/LiveSubs/SessionStore.swift
@@ -31,11 +31,10 @@ struct Session: Codable, Identifiable, Equatable {
/// ("11月1日 产品路线评审", in the notes' language), else "会议 11月1日 14:30".
var displayTitle: String {
if renamed ?? !title.hasPrefix("会议 ") { return title }
- guard let name = notes?.title, !name.isEmpty else { return title }
- let f = DateFormatter()
- f.locale = Locale(identifier: "zh_CN")
- f.dateFormat = Calendar.current.isDate(startedAt, equalTo: Date(), toGranularity: .year) ? "M月d日" : "yyyy年M月d日"
- return "\(f.string(from: startedAt)) \(name)"
+ // The stored default title is Chinese ("会议 11月1日 14:30"); shown in the UI language.
+ guard let name = notes?.title, !name.isEmpty else { return L("会议 \(dateText(startedAt, "MMMdHHmm"))") }
+ let thisYear = Calendar.current.isDate(startedAt, equalTo: Date(), toGranularity: .year)
+ return "\(dateText(startedAt, thisYear ? "MMMd" : "yMMMd")) \(name)"
}
static func defaultTitle(_ date: Date) -> String {
@@ -76,6 +75,11 @@ final class SessionStore: ObservableObject {
if let data = try? Data(contentsOf: dir.appendingPathComponent("session.json")),
var s = try? decoder.decode(Session.self, from: data) {
if s.endedAt == nil { s.endedAt = s.lines.last.map { s.startedAt.addingTimeInterval($0.t + 5) } ?? s.startedAt }
+ // The app quit mid-meeting: its recording is still in the partial file.
+ if s.id != liveID, hasPartialAudio(s.id) {
+ s.hasAudio = true
+ finishAudio(s.id)
+ }
out.append(s)
}
}
@@ -107,9 +111,21 @@ final class SessionStore: ObservableObject {
sessions.remove(at: i)
return
}
- sessions[i].hasAudio = FileManager.default.fileExists(atPath: systemAudioURL(id).path)
- || FileManager.default.fileExists(atPath: micAudioURL(id).path)
+ sessions[i].hasAudio = [systemAudioURL(id), micAudioURL(id)].contains {
+ FileManager.default.fileExists(atPath: $0.path) || FileManager.default.fileExists(atPath: AudioFileWriter.partial($0).path)
+ }
saveNow(id)
+ finishAudio(id)
+ }
+
+ private func hasPartialAudio(_ id: String) -> Bool {
+ [systemAudioURL(id), micAudioURL(id)].contains { FileManager.default.fileExists(atPath: AudioFileWriter.partial($0).path) }
+ }
+
+ /// Turns the meeting's recordings into .m4a files (call after the recorders are closed).
+ func finishAudio(_ id: String) {
+ let urls = [systemAudioURL(id), micAudioURL(id)]
+ Task.detached(priority: .utility) { for u in urls { await AudioFileWriter.finish(u) } }
}
var liveStart: Date? { liveID.flatMap { index($0) }.map { sessions[$0].startedAt } }
@@ -189,20 +205,17 @@ enum TranscriptExport {
: String(format: "%02d:%02d", s / 60, s % 60)
}
- static func speakerName(_ line: TranscriptLine) -> String { line.speaker == "me" ? "你" : "对方" }
+ static func speakerName(_ line: TranscriptLine) -> String { line.speaker == "me" ? L("你") : L("对方") }
static func header(_ s: Session) -> String {
- let f = DateFormatter()
- f.locale = Locale(identifier: "zh_CN")
- f.dateFormat = "yyyy年M月d日 HH:mm"
let mins = Int(s.duration / 60)
- return "\(f.string(from: s.startedAt)) · " + (mins < 1 ? "不到 1 分钟" : "\(mins) 分钟")
+ return "\(dateText(s.startedAt, "yMMMdHHmm")) · " + (mins < 1 ? L("不到 1 分钟") : L("\(mins) 分钟"))
}
/// The notes as Markdown (empty when there are none).
static func notesMarkdown(_ n: MeetingNotes?) -> String {
guard let n, !n.isEmpty else { return "" }
- var out = "## 纪要\n\n\(n.summary)\n\n"
+ var out = "## \(L("纪要"))\n\n\(n.summary)\n\n"
for t in n.topics {
out += "### \(clock(t.start)) \(t.title)\n\n"
if !t.summary.isEmpty { out += "\(t.summary)\n\n" }
@@ -213,12 +226,12 @@ enum TranscriptExport {
}
out += "\n"
}
- if !n.conclusions.isEmpty { out += "### 结论\n\n" + n.conclusions.map { "- \($0.text)\n" }.joined() + "\n" }
+ if !n.conclusions.isEmpty { out += "### \(L("结论"))\n\n" + n.conclusions.map { "- \($0.text)\n" }.joined() + "\n" }
if !n.todos.isEmpty {
- out += "### 待办\n\n" + n.todos.map { "- [ ] \($0.text)" + ($0.owner.map { "(\($0))" } ?? "") + "\n" }.joined() + "\n"
+ out += "### \(L("待办"))\n\n" + n.todos.map { "- [ ] \($0.text)" + ($0.owner.map { "(\($0))" } ?? "") + "\n" }.joined() + "\n"
}
if !n.terms.isEmpty {
- out += "### 人名和术语\n\n" + n.terms.map { "- **\($0.name)** \($0.note)\n" }.joined() + "\n"
+ out += "### \(L("人名和术语"))\n\n" + n.terms.map { "- **\($0.name)** \($0.note)\n" }.joined() + "\n"
}
return out
}
@@ -226,7 +239,7 @@ enum TranscriptExport {
static func markdown(_ s: Session) -> String {
var out = "# \(s.displayTitle)\n\n\(header(s))\n\n"
let notes = notesMarkdown(s.notes)
- if !notes.isEmpty { out += notes + "## 文字记录\n\n" }
+ if !notes.isEmpty { out += notes + "## \(L("文字记录"))\n\n" }
for l in s.lines {
out += "**[\(clock(l.t))] \(speakerName(l))** \n\(l.src)\n"
if let d = l.dst, d != l.src { out += "> \(d)\n" }
@@ -265,7 +278,7 @@ enum TranscriptExport {
add(s.displayTitle, size: 20, weight: .bold, after: 6)
add(header(s), size: 10, color: .darkGray, after: 14)
if let n = s.notes, !n.isEmpty {
- add("纪要", size: 15, weight: .bold, after: 6)
+ add(L("纪要"), size: 15, weight: .bold, after: 6)
add(n.summary, size: 11, after: 10)
for t in n.topics {
add("\(clock(t.start)) \(t.title)", size: 12, weight: .semibold, after: 3)
@@ -278,14 +291,14 @@ enum TranscriptExport {
add("", size: 6, after: 4)
}
if !n.conclusions.isEmpty {
- add("结论", size: 12, weight: .semibold, after: 3)
+ add(L("结论"), size: 12, weight: .semibold, after: 3)
for c in n.conclusions { add("• \(c.text)", size: 11, after: 2) }
}
if !n.todos.isEmpty {
- add("待办", size: 12, weight: .semibold, after: 3)
+ add(L("待办"), size: 12, weight: .semibold, after: 3)
for t in n.todos { add("☐ \(t.text)" + (t.owner.map { "(\($0))" } ?? ""), size: 11, after: 2) }
}
- add("文字记录", size: 15, weight: .bold, after: 6)
+ add(L("文字记录"), size: 15, weight: .bold, after: 6)
}
for l in s.lines {
add("[\(clock(l.t))] \(speakerName(l))", size: 9, weight: .semibold, color: .darkGray, after: 2)
diff --git a/Sources/LiveSubs/SettingsWindow.swift b/Sources/LiveSubs/SettingsWindow.swift
index 072c626..c36e164 100644
--- a/Sources/LiveSubs/SettingsWindow.swift
+++ b/Sources/LiveSubs/SettingsWindow.swift
@@ -7,12 +7,12 @@ enum SettingsSection: String, CaseIterable, Identifiable {
var id: String { rawValue }
var title: String {
switch self {
- case .overlay: "显示"
- case .language: "语言"
- case .speak: "同声传译"
- case .records: "会议记录"
- case .ai: "AI 服务"
- case .diagnostics: "诊断"
+ case .overlay: L("显示")
+ case .language: L("语言")
+ case .speak: L("同声传译")
+ case .records: L("会议记录")
+ case .ai: L("AI 服务")
+ case .diagnostics: L("诊断")
}
}
var icon: String {
@@ -92,7 +92,7 @@ struct Segments: View {
}
/// The 字幕 choices.
-let subtitleOptions: [(id: String, title: String)] = [("both", "原文 + 译文"), ("translation", "只看译文"), ("original", "只看原文")]
+let subtitleOptions: [(id: String, title: String)] = [("both", L("原文 + 译文")), ("translation", L("只看译文")), ("original", L("只看原文"))]
/// A grey pill that opens a menu: the value and a small chevron.
struct PillMenu: View {
@@ -165,7 +165,7 @@ struct ShortcutField: View {
Button { recording ? stop() : start() } label: {
HStack(spacing: 4) {
if recording {
- Text(role == .talk ? "按下组合键,或单按右 ⌥" : "按下新的组合键")
+ Text(role == .talk ? L("按下组合键,或单按右 ⌥") : L("按下新的组合键"))
.font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.accentInk)
} else {
ForEach(Array(current.keys.enumerated()), id: \.offset) { KeyCap($0.element) }
@@ -177,7 +177,7 @@ struct ShortcutField: View {
.contentShape(Rectangle())
}
.buttonStyle(.plain)
- .help(recording ? "按 esc 取消" : "点击更换按键")
+ .help(recording ? L("按 esc 取消") : L("点击更换按键"))
}
if let error {
Text(error).font(.system(size: 11)).foregroundStyle(Palette.accentInk)
@@ -235,14 +235,14 @@ struct ShortcutField: View {
struct TalkKeyPermissionRow: View {
@ObservedObject var model: AppModel
var body: some View {
- SettingsRow(title: "还差一步:允许“输入监控”",
- detail: "“按住右 ⌥ 说话”需要此权限。请在系统设置中勾选 \(appDisplayName),返回此处即可生效") {
- SoftButton("去允许", dark: true) { model.allowTalkKey() }
+ SettingsRow(title: L("还差一步:允许“输入监控”"),
+ detail: L("“按住右 ⌥ 说话”需要此权限。请在系统设置中勾选 \(appDisplayName),返回此处即可生效")) {
+ SoftButton(L("去允许"), dark: true) { model.allowTalkKey() }
}
}
}
-let appDisplayName = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String ?? "知了"
+let appDisplayName = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String ?? L("知了")
// MARK: - Virtual microphone checklist
@@ -274,7 +274,7 @@ struct MicSetupCard: View {
Text("\(deviceName ?? "BlackHole 2ch") · 试音通过,对方听得到").font(.system(size: 11)).foregroundStyle(Palette.tertiary)
}
Spacer()
- SoftButton("再试一次") { installer.runTest() }
+ SoftButton(L("再试一次")) { installer.runTest() }
}
if let t = installer.test { TestResultView(result: t) }
}
@@ -289,13 +289,13 @@ struct MicSetupCard: View {
Text(statusTag).font(.system(size: 11, weight: .semibold))
.foregroundStyle(installer.busy ? Palette.accentInk : Palette.tertiary)
}
- step(1, "安装", "输一次电脑密码", done: onDisk,
+ step(1, L("安装"), L("输一次电脑密码"), done: onDisk,
active: installer.state == .downloading || installer.state == .installing,
- activeText: installer.state == .downloading ? "正在下载…" : "正在安装…")
- step(2, "让系统认出它", "声音会短暂中断约 1 秒", done: loaded,
- active: installer.state == .reloading, activeText: "正在让系统认出它…")
- step(3, "试音", "自动播一句,确认对方听得到", done: installer.passed,
- active: installer.state == .testing, activeText: "正在试音…")
+ activeText: installer.state == .downloading ? L("正在下载…") : L("正在安装…"))
+ step(2, L("让系统认出它"), L("声音会短暂中断约 1 秒"), done: loaded,
+ active: installer.state == .reloading, activeText: L("正在让系统认出它…"))
+ step(3, L("试音"), L("自动播一句,确认对方听得到"), done: installer.passed,
+ active: installer.state == .testing, activeText: L("正在试音…"))
if let t = installer.test, !t.heard, installer.state != .testing {
TestResultView(result: t)
}
@@ -310,16 +310,16 @@ struct MicSetupCard: View {
}
private var statusTag: String {
- if installer.busy { return "进行中" }
- if !onDisk { return "没装" }
- if !loaded { return "系统还没认出" }
- return installer.test == nil ? "还没试音" : "没听到声音"
+ if installer.busy { return L("进行中") }
+ if !onDisk { return L("没装") }
+ if !loaded { return L("系统还没认出") }
+ return installer.test == nil ? L("还没试音") : L("没听到声音")
}
private var buttonTitle: String {
- if !onDisk { return "一键安装" }
- if !loaded { return "让系统认出它" }
- return installer.test == nil ? "试音" : "再试一次"
+ if !onDisk { return L("一键安装") }
+ if !loaded { return L("让系统认出它") }
+ return installer.test == nil ? L("试音") : L("再试一次")
}
private func step(_ n: Int, _ title: String, _ detail: String, done: Bool, active: Bool, activeText: String) -> some View {
@@ -359,10 +359,10 @@ struct TestResultView: View {
}
.frame(height: 24) }
if result.heard {
- (Text("对方会听到:") + Text(result.text.isEmpty ? "一段声音" : "“\(result.text)”").bold())
+ (Text("对方会听到:") + Text(result.text.isEmpty ? L("一段声音") : "“\(result.text)”").bold())
.font(.system(size: 12)).foregroundStyle(Palette.ink)
} else {
- Text(result.problem ?? "虚拟麦克风未收到声音,请再试一次").font(.system(size: 12)).foregroundStyle(Palette.accentInk)
+ Text(result.problem ?? L("虚拟麦克风未收到声音,请再试一次")).font(.system(size: 12)).foregroundStyle(Palette.accentInk)
}
Spacer(minLength: 0)
}
@@ -381,26 +381,29 @@ struct SettingsView: View {
var body: some View {
HStack(spacing: 0) {
sidebar.frame(width: 190)
- ScrollView {
- VStack(alignment: .leading, spacing: 16) {
- Text(model.settingsSection.title).font(.system(size: 20, weight: .bold)).foregroundStyle(Palette.ink)
- switch model.settingsSection {
- case .speak: speak
- case .overlay: overlay
- case .language: LanguageSettings(model: model, settings: settings)
- case .records: records
- case .ai: AISettingsView(model: model, ling: model.ling, settings: settings)
- case .diagnostics: DiagnosticsView(diagnostics: model.diagnostics, model: settings.aiModel)
- }
- }
- .padding(.leading, 12).padding(.trailing, 28).padding(.top, 40).padding(.bottom, 28)
- .frame(maxWidth: .infinity, alignment: .leading)
- }
+ ScrollView { page }
}
.frame(width: 720, height: 600)
.background(Color(red: 0.965, green: 0.969, blue: 0.976))
}
+ /// The current section without the scroll view (also drawn by the `settingsRender` debug command).
+ var page: some View {
+ VStack(alignment: .leading, spacing: 16) {
+ Text(model.settingsSection.title).font(.system(size: 20, weight: .bold)).foregroundStyle(Palette.ink)
+ switch model.settingsSection {
+ case .speak: speak
+ case .overlay: overlay
+ case .language: LanguageSettings(model: model, settings: settings)
+ case .records: records
+ case .ai: AISettingsView(model: model, ling: model.ling, settings: settings)
+ case .diagnostics: DiagnosticsView(diagnostics: model.diagnostics, model: settings.aiModel)
+ }
+ }
+ .padding(.leading, 12).padding(.trailing, 28).padding(.top, 40).padding(.bottom, 28)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ }
+
private var sidebar: some View {
VStack(alignment: .leading, spacing: 2) {
ForEach(SettingsSection.allCases.filter { $0 != .diagnostics || settings.diagnostics }) { s in
@@ -429,10 +432,11 @@ struct SettingsView: View {
// Diagnostics is for chasing slowness: off it leaves no trace in the sidebar.
HStack(spacing: 8) {
Text("诊断").font(.system(size: 12)).foregroundStyle(settings.diagnostics ? Palette.ink : Palette.secondary)
+ .fixedSize()
Toggle("诊断", isOn: Binding(get: { settings.diagnostics }, set: { model.setDiagnostics($0) }))
.toggleStyle(.switch).labelsHidden().controlSize(.mini).tint(Palette.ink)
Spacer()
- Text(Self.version).font(.system(size: 11).monospacedDigit()).foregroundStyle(Palette.tertiary)
+ Text(Self.version).font(.system(size: 11).monospacedDigit()).foregroundStyle(Palette.tertiary).fixedSize()
}
.padding(.horizontal, 10).padding(.top, 10)
.overlay(alignment: .top) { Rectangle().fill(Palette.line).frame(height: 1) }
@@ -450,21 +454,21 @@ struct SettingsView: View {
.padding(.top, -8)
SettingsCard { MicSetupCard(installer: installer, deviceName: model.virtualMic?.name) }
SettingsCard {
- SettingsRow(title: "把我的话翻译给对方听") {
+ SettingsRow(title: L("把我的话翻译给对方听")) {
Toggle("把我说的翻译给对方", isOn: Binding(get: { settings.speakEnabled }, set: { model.enableSpeaking($0) }))
.toggleStyle(.switch).labelsHidden().controlSize(.small).tint(Palette.ink)
}
- SettingsRow(title: "按住说话",
- detail: settings.talkKey.isRightOption ? "单独按住右侧 ⌥;与其他键同时按不会触发" : nil) {
+ SettingsRow(title: L("按住说话"),
+ detail: settings.talkKey.isRightOption ? L("单独按住右侧 ⌥;与其他键同时按不会触发") : nil) {
ShortcutField(model: model, role: .talk)
}
if settings.speakEnabled && model.talkNeedsPermission { TalkKeyPermissionRow(model: model) }
- SettingsRow(title: "语言", detail: "说\(settings.speakFromLang.name),对方听到\(targetName(model.speak.targetCode))") {
- SoftButton("修改") { model.settingsSection = .language }
+ SettingsRow(title: L("语言"), detail: L("说\(settings.speakFromLang.name),对方听到\(targetName(model.speak.targetCode))")) {
+ SoftButton(L("修改")) { model.settingsSection = .language }
}
- SettingsRow(title: "声音输出到", divider: false) {
+ SettingsRow(title: L("声音输出到"), divider: false) {
PillMenu(value: outputName,
- options: [("", "虚拟麦克风(自动)")] + model.outputs.map { ($0.uid, $0.name) }) {
+ options: [("", L("虚拟麦克风(自动)"))] + model.outputs.map { ($0.uid, $0.name) }) {
settings.speakOutput = $0
}
}
@@ -476,14 +480,14 @@ struct SettingsView: View {
}
private var outputName: String {
- if settings.speakOutput.isEmpty { return "虚拟麦克风(自动)" }
- return model.outputs.first { $0.uid == settings.speakOutput }?.name ?? "虚拟麦克风(自动)"
+ if settings.speakOutput.isEmpty { return L("虚拟麦克风(自动)") }
+ return model.outputs.first { $0.uid == settings.speakOutput }?.name ?? L("虚拟麦克风(自动)")
}
private var overlay: some View {
VStack(alignment: .leading, spacing: 14) {
SettingsCard {
- SettingsRow(title: "听的时候显示", detail: "选择任意模式都会正常保存记录、生成纪要") {
+ SettingsRow(title: L("听的时候显示"), detail: L("选择任意模式都会正常保存记录、生成纪要")) {
Picker("显示方式", selection: Binding(get: { settings.displayMode }, set: { model.setDisplayMode($0) })) {
Text("实时纪要").tag("notes")
Text("字幕条").tag("bar")
@@ -491,13 +495,13 @@ struct SettingsView: View {
}
.pickerStyle(.segmented).labelsHidden().frame(width: 210)
}
- SettingsRow(title: "切换显示方式", detail: model.toggleKeyTaken ? "被其他应用占用了,点右边换一个" : "实时纪要 → 字幕条 → 不显示", divider: false) {
+ SettingsRow(title: L("切换显示方式"), detail: model.toggleKeyTaken ? L("被其他应用占用了,点右边换一个") : L("实时纪要 → 字幕条 → 不显示"), divider: false) {
ShortcutField(model: model, role: .toggle)
}
}
Text("字幕条").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.secondary).padding(.top, 4)
SettingsCard {
- SettingsRow(title: "字幕条显示时机") {
+ SettingsRow(title: L("字幕条显示时机")) {
Picker("显示", selection: Binding(get: { settings.overlayAuto }, set: { model.setOverlayAuto($0) })) {
Text("有人说话时").tag(true)
Text("始终显示").tag(false)
@@ -505,7 +509,7 @@ struct SettingsView: View {
.pickerStyle(.segmented).labelsHidden().frame(width: 140)
}
if settings.overlayAuto {
- SettingsRow(title: "安静多久后收起") {
+ SettingsRow(title: L("安静多久后收起")) {
Picker("收起", selection: $settings.overlayHideAfter) {
Text("2 秒").tag(2.0)
Text("4 秒").tag(4.0)
@@ -514,8 +518,8 @@ struct SettingsView: View {
.pickerStyle(.segmented).labelsHidden().frame(width: 140)
}
}
- SettingsRow(title: "位置和大小", detail: "鼠标悬停可拖动位置,拖拽右下角可缩放大小", divider: false) {
- SoftButton("恢复默认") { model.overlay.resetPosition() }
+ SettingsRow(title: L("位置和大小"), detail: L("鼠标悬停可拖动位置,拖拽右下角可缩放大小"), divider: false) {
+ SoftButton(L("恢复默认")) { model.overlay.resetPosition() }
}
}
}
@@ -523,15 +527,15 @@ struct SettingsView: View {
private var records: some View {
SettingsCard {
- SettingsRow(title: "保存会议录音", detail: "只存在这台 Mac 上") {
+ SettingsRow(title: L("保存会议录音"), detail: L("只存在这台 Mac 上")) {
Toggle("保存会议录音", isOn: $settings.recordAudio)
.toggleStyle(.switch).labelsHidden().controlSize(.small).tint(Palette.ink)
}
- SettingsRow(title: "记录文件夹") {
- SoftButton("打开") { NSWorkspace.shared.open(model.store.root) }
+ SettingsRow(title: L("记录文件夹")) {
+ SoftButton(L("打开")) { NSWorkspace.shared.open(model.store.root) }
}
- SettingsRow(title: "首次引导", divider: false) {
- SoftButton("重新看") { model.onboardingStep = 1; model.openOnboarding?() }
+ SettingsRow(title: L("首次引导"), divider: false) {
+ SoftButton(L("重新看")) { model.onboardingStep = 1; model.openOnboarding?() }
}
}
}
diff --git a/Sources/LiveSubs/Shortcuts.swift b/Sources/LiveSubs/Shortcuts.swift
index 4c4c2fb..186ac7d 100644
--- a/Sources/LiveSubs/Shortcuts.swift
+++ b/Sources/LiveSubs/Shortcuts.swift
@@ -38,7 +38,7 @@ struct Shortcut: Equatable {
/// Key caps in display order, e.g. ["⌃", "⌥", "S"].
var keys: [String] {
- if isRightOption { return ["右 ⌥"] }
+ if isRightOption { return [L("右 ⌥")] }
var k: [String] = []
if modifiers & controlKey != 0 { k.append("⌃") }
if modifiers & optionKey != 0 { k.append("⌥") }
@@ -59,7 +59,7 @@ struct Shortcut: Equatable {
private static let named: [Int: String] = [
kVK_Space: "Space", kVK_Return: "↩", kVK_Tab: "⇥", kVK_Delete: "⌫", kVK_ForwardDelete: "⌦",
kVK_Escape: "esc", kVK_LeftArrow: "←", kVK_RightArrow: "→", kVK_UpArrow: "↑", kVK_DownArrow: "↓",
- kVK_Home: "↖", kVK_End: "↘", kVK_PageUp: "⇞", kVK_PageDown: "⇟", kVK_RightOption: "右 ⌥",
+ kVK_Home: "↖", kVK_End: "↘", kVK_PageUp: "⇞", kVK_PageDown: "⇟", kVK_RightOption: L("右 ⌥"),
]
/// The character the key types on the current layout (US letters on non-Latin layouts).
@@ -86,7 +86,7 @@ struct Shortcut: Equatable {
/// most Mac keyboards. So a combination needs ⌃ or ⌘.
var typingProblem: String? {
if isRightOption { return nil }
- if modifiers & (controlKey | cmdKey) == 0 { return "请包含 ⌃ 或 ⌘,否则会影响正常打字" }
+ if modifiers & (controlKey | cmdKey) == 0 { return L("请包含 ⌃ 或 ⌘,否则会影响正常打字") }
return nil
}
diff --git a/Sources/LiveSubs/SpeakEngine.swift b/Sources/LiveSubs/SpeakEngine.swift
index f54bfa8..337186c 100644
--- a/Sources/LiveSubs/SpeakEngine.swift
+++ b/Sources/LiveSubs/SpeakEngine.swift
@@ -143,7 +143,7 @@ final class SpeakEngine {
do {
if await AssetInventory.status(forModules: [t]) != .installed,
let req = try await AssetInventory.assetInstallationRequest(supporting: [t]) {
- onStatus?("正在下载 \(lang.name) 语音模型…")
+ onStatus?(L("正在下载 \(lang.name) 语音模型…"))
try await req.downloadAndInstall()
}
analyzerFormat = await SpeechAnalyzer.bestAvailableAudioFormat(compatibleWith: [t])
@@ -152,7 +152,7 @@ final class SpeakEngine {
debugLog("speak transcriber ready locale=\(lang.locale)")
} catch {
debugLog("speak transcriber failed: \(error)")
- onStatus?("无法准备语音识别:\(error.localizedDescription)")
+ onStatus?(L("无法准备语音识别:\(error.localizedDescription)"))
}
}
@@ -220,7 +220,7 @@ final class SpeakEngine {
guard settings.speakEnabled, phase == .idle || phase == .speaking else { return }
guard let format = analyzerFormat, let input = beginUtterance() else {
Task { await prepare() }
- onStatus?("语音识别仍在准备中,请再按一次")
+ onStatus?(L("语音识别仍在准备中,请再按一次"))
return
}
debugLog("speak: press began")
@@ -281,7 +281,7 @@ final class SpeakEngine {
let inputNode = mic.inputNode
let inFormat = inputNode.outputFormat(forBus: 0)
guard inFormat.sampleRate > 0 else {
- onStatus?("没有可用的麦克风")
+ onStatus?(L("没有可用的麦克风"))
phase = .idle
return
}
@@ -303,7 +303,7 @@ final class SpeakEngine {
try mic.start()
} catch {
debugLog("mic start failed: \(error)")
- onStatus?("麦克风无法启动,请在系统设置里允许\(appDisplayName)使用麦克风")
+ onStatus?(L("麦克风无法启动,请在系统设置里允许\(appDisplayName)使用麦克风"))
phase = .idle
}
}
@@ -336,7 +336,7 @@ final class SpeakEngine {
private nonisolated func recordMic(_ buffer: AVAudioPCMBuffer) {
guard let url = micRecordURL else { return }
- if micRecorder == nil { micRecorder = AudioFileWriter.open(url, format: buffer.format) }
+ if micRecorder == nil { micRecorder = AudioFileWriter.open(AudioFileWriter.partial(url), format: buffer.format) }
try? micRecorder?.write(from: buffer)
}
@@ -398,7 +398,7 @@ final class SpeakEngine {
debugLog("speak: translation failed, nothing sent")
onTiming?(timing(voice: nil))
phase = .idle
- onLive?(.idle, text, "翻译失败,这句话未发送")
+ onLive?(.idle, text, L("翻译失败,这句话未发送"))
return
}
contentLog("SPEAK [\(from)→\(to)] via=\(trace.via) \(text) => \(translated)")
diff --git a/Sources/LiveSubs/SystemAudioTap.swift b/Sources/LiveSubs/SystemAudioTap.swift
index 4fb4c94..7c72ff2 100644
--- a/Sources/LiveSubs/SystemAudioTap.swift
+++ b/Sources/LiveSubs/SystemAudioTap.swift
@@ -80,10 +80,10 @@ final class SystemAudioTap {
var tap = AudioObjectID(kAudioObjectUnknown)
var status = AudioHardwareCreateProcessTap(desc, &tap)
- guard status == noErr else { throw fail(Int(status), "无法创建系统音频 Tap(\(status))") }
+ guard status == noErr else { throw fail(Int(status), L("无法创建系统音频 Tap(\(status))")) }
tapID = tap
- guard let outputUID = Self.defaultOutputUID() else { throw fail(-1, "找不到默认输出设备") }
+ guard let outputUID = Self.defaultOutputUID() else { throw fail(-1, L("找不到默认输出设备")) }
let aggregateUID = "com.wquguru.cicada.\(UUID().uuidString)"
let aggregate: [String: Any] = [
@@ -101,7 +101,7 @@ final class SystemAudioTap {
]
var aggregateID = AudioObjectID(kAudioObjectUnknown)
status = AudioHardwareCreateAggregateDevice(aggregate as CFDictionary, &aggregateID)
- guard status == noErr else { throw fail(Int(status), "无法创建音频聚合设备(\(status))") }
+ guard status == noErr else { throw fail(Int(status), L("无法创建音频聚合设备(\(status))")) }
self.aggregateID = aggregateID
var component = AudioComponentDescription(
@@ -111,10 +111,10 @@ final class SystemAudioTap {
componentFlags: 0,
componentFlagsMask: 0
)
- guard let found = AudioComponentFindNext(nil, &component) else { throw fail(-2, "找不到 HAL 音频组件") }
+ guard let found = AudioComponentFindNext(nil, &component) else { throw fail(-2, L("找不到 HAL 音频组件")) }
var unit: AudioUnit?
status = AudioComponentInstanceNew(found, &unit)
- guard status == noErr, let unit else { throw fail(Int(status), "无法创建音频单元(\(status))") }
+ guard status == noErr, let unit else { throw fail(Int(status), L("无法创建音频单元(\(status))")) }
audioUnit = unit
var disableOutput: UInt32 = 0
@@ -127,7 +127,7 @@ final class SystemAudioTap {
var device = aggregateID
status = AudioUnitSetProperty(unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0,
&device, UInt32(MemoryLayout<AudioObjectID>.size))
- guard status == noErr else { throw fail(Int(status), "无法连接音频聚合设备(\(status))") }
+ guard status == noErr else { throw fail(Int(status), L("无法连接音频聚合设备(\(status))")) }
var asbd = AudioStreamBasicDescription(
mSampleRate: 48_000,
@@ -140,7 +140,7 @@ final class SystemAudioTap {
mBitsPerChannel: 32,
mReserved: 0
)
- guard let clientFormat = AVAudioFormat(streamDescription: &asbd) else { throw fail(-3, "无法创建音频格式") }
+ guard let clientFormat = AVAudioFormat(streamDescription: &asbd) else { throw fail(-3, L("无法创建音频格式")) }
self.clientFormat = clientFormat
self.monoFormat = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: 48_000, channels: 1, interleaved: false)
// Pre-allocate so the real-time callback normally doesn't allocate.
@@ -148,7 +148,7 @@ final class SystemAudioTap {
status = AudioUnitSetProperty(unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1,
&asbd, UInt32(MemoryLayout<AudioStreamBasicDescription>.size))
- guard status == noErr else { throw fail(Int(status), "无法设置音频格式(\(status))") }
+ guard status == noErr else { throw fail(Int(status), L("无法设置音频格式(\(status))")) }
var callback = AURenderCallbackStruct(
inputProc: { refCon, _, timestamp, bus, frames, _ in
@@ -159,12 +159,12 @@ final class SystemAudioTap {
)
status = AudioUnitSetProperty(unit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0,
&callback, UInt32(MemoryLayout<AURenderCallbackStruct>.size))
- guard status == noErr else { throw fail(Int(status), "无法设置音频回调(\(status))") }
+ guard status == noErr else { throw fail(Int(status), L("无法设置音频回调(\(status))")) }
status = AudioUnitInitialize(unit)
- guard status == noErr else { throw fail(Int(status), "无法初始化音频单元(\(status))") }
+ guard status == noErr else { throw fail(Int(status), L("无法初始化音频单元(\(status))")) }
status = AudioOutputUnitStart(unit)
- guard status == noErr else { throw fail(Int(status), "无法启动音频采集(\(status))") }
+ guard status == noErr else { throw fail(Int(status), L("无法启动音频采集(\(status))")) }
}
private func render(timestamp: UnsafePointer<AudioTimeStamp>, bus: UInt32, frames: UInt32) -> OSStatus {
diff --git a/Sources/LiveSubs/Views.swift b/Sources/LiveSubs/Views.swift
index de104fc..3917ea1 100644
--- a/Sources/LiveSubs/Views.swift
+++ b/Sources/LiveSubs/Views.swift
@@ -44,11 +44,12 @@ struct ChoiceRow: View {
}
} label: {
HStack(spacing: 10) {
- Text(label).font(.system(size: 12)).foregroundStyle(Palette.secondary).frame(width: 44, alignment: .leading)
+ Text(label).font(.system(size: 12)).foregroundStyle(Palette.secondary).frame(width: uiIsChinese ? 44 : 72, alignment: .leading)
Text(value).font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.ink).lineLimit(1)
if let badge {
Text(badge)
.font(.system(size: 10, weight: .semibold))
+ .lineLimit(1).fixedSize()
.foregroundStyle(Palette.accentInk)
.padding(.horizontal, 7).padding(.vertical, 2)
.background(Capsule().fill(Palette.accentPale))
@@ -75,22 +76,35 @@ struct MenuPanelView: View {
private var sourceOptions: [(id: String, title: String)] {
let auto = model.candidates.map(\.name).joined(separator: "、")
- return [("auto", auto.isEmpty ? "自动识别" : "自动识别(\(auto))")] + sourceLanguages.map {
- ($0.locale, model.installed.isEmpty || model.installed.contains($0.locale) ? $0.name : "\($0.name)(需下载)")
+ return [("auto", auto.isEmpty ? L("自动识别") : L("自动识别(\(auto))"))] + sourceLanguages.map {
+ ($0.locale, model.installed.isEmpty || model.installed.contains($0.locale) ? $0.name : L("\($0.name)(需下载)"))
}
}
private var targetOptions: [(id: String, title: String)] {
- [("system", "跟随系统(\(settings.systemTargetDescription()))")] + targetLanguages.map { ($0.code, $0.name) }
+ [("system", L("跟随系统(\(settings.systemTargetDescription()))"))] + targetLanguages.map { ($0.code, $0.name) }
}
private var heardValue: (String, String?) {
switch settings.sourceMode {
case .fixed(let l): return (l.name, nil)
- case .auto: return (model.listen.activeLang?.name ?? "自动", "自动识别")
+ case .auto: return (model.listen.activeLang?.name ?? L("自动"), L("自动识别"))
}
}
+ private var displayTitle: some View {
+ Text("显示").font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.ink)
+ }
+
+ private var displayPicker: some View {
+ Picker("显示", selection: Binding(get: { settings.displayMode }, set: { model.setDisplayMode($0) })) {
+ Text("实时纪要").tag("notes")
+ Text("字幕条").tag("bar")
+ Text("不显示").tag("none")
+ }
+ .pickerStyle(.segmented).labelsHidden()
+ }
+
var body: some View {
VStack(alignment: .leading, spacing: 16) {
HStack(spacing: 12) {
@@ -110,7 +124,7 @@ struct MenuPanelView: View {
}
HStack(spacing: 6) {
Circle().fill(model.running ? Palette.accent : Color.gray.opacity(0.5)).frame(width: 7, height: 7)
- Text(model.running ? model.summary : "已暂停")
+ Text(model.running ? model.summary : L("已暂停"))
.font(.system(size: 12)).foregroundStyle(Palette.secondary).lineLimit(1)
}
}
@@ -120,17 +134,18 @@ struct MenuPanelView: View {
}
VStack(spacing: 8) {
- ChoiceRow(label: "听到", value: heardValue.0, badge: heardValue.1, options: sourceOptions) {
+ ChoiceRow(label: L("听到"), value: heardValue.0, badge: heardValue.1, options: sourceOptions) {
model.sourceSelection = $0
}
- ChoiceRow(label: "翻译成",
+ ChoiceRow(label: L("翻译成"),
value: targetName(model.listen.resolvedTarget),
- badge: settings.target == "system" ? "跟随系统" : nil,
+ // "Follow system" leaves no room for the language name in the panel.
+ badge: settings.target == "system" ? (uiIsChinese ? L("跟随系统") : L("系统")) : nil,
options: targetOptions) {
model.targetSelection = $0
}
- ChoiceRow(label: "字幕", value: subtitleOptions.first { $0.id == model.subtitles }?.title ?? "原文 + 译文",
- badge: model.meetingSubtitles != nil ? "仅本场" : nil, options: subtitleOptions) {
+ ChoiceRow(label: L("字幕"), value: subtitleOptions.first { $0.id == model.subtitles }?.title ?? L("原文 + 译文"),
+ badge: model.meetingSubtitles != nil ? L("仅本场") : nil, options: subtitleOptions) {
model.setSubtitles($0)
}
}
@@ -156,7 +171,7 @@ struct MenuPanelView: View {
HStack {
Text("虚拟麦克风尚未设置好,对方听不到你的声音").font(.system(size: 12)).foregroundStyle(Palette.accentInk)
Spacer()
- SoftButton("设置") { model.openSettings(.speak) }
+ SoftButton(L("设置")) { model.openSettings(.speak) }
}
.padding(10).frame(maxWidth: .infinity, alignment: .leading)
.background(RoundedRectangle(cornerRadius: 9).fill(Palette.accentPale))
@@ -165,22 +180,26 @@ struct MenuPanelView: View {
Divider()
VStack(spacing: 10) {
- HStack {
- Text("显示").font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.ink)
- Spacer()
- Picker("显示", selection: Binding(get: { settings.displayMode }, set: { model.setDisplayMode($0) })) {
- Text("实时纪要").tag("notes")
- Text("字幕条").tag("bar")
- Text("不显示").tag("none")
+ // English labels are wider than the 210 pt the Chinese ones fit in: the picker gets its own row.
+ if uiIsChinese {
+ HStack {
+ displayTitle
+ Spacer()
+ displayPicker.frame(width: 210)
+ }
+ } else {
+ VStack(alignment: .leading, spacing: 8) {
+ displayTitle
+ displayPicker
}
- .pickerStyle(.segmented).labelsHidden().frame(width: 210)
+ .frame(maxWidth: .infinity, alignment: .leading)
}
if settings.displayMode == "notes" {
HStack {
- Text(model.ling.hasKey ? "纪要、文字记录和字幕都在一个窗口里" : "填入 API key 后可生成纪要;文字记录照常保存")
+ Text(model.ling.hasKey ? L("纪要、文字记录和字幕都在一个窗口里") : L("填入 API key 后可生成纪要;文字记录照常保存"))
.font(.system(size: 12)).foregroundStyle(Palette.secondary)
Spacer()
- SoftButton("打开") { model.openNotesWindow() }
+ SoftButton(L("打开")) { model.openNotesWindow() }
}
}
if settings.displayMode == "bar" {
@@ -334,17 +353,15 @@ struct MainWindowView: View {
/// 今天 / 昨天 / 本周 / then one group per month, newest first.
private var groups: [(title: String, sessions: [Session])] {
let cal = Calendar.current
- let f = DateFormatter()
- f.locale = Locale(identifier: "zh_CN")
var out: [(title: String, sessions: [Session])] = []
for s in filtered {
let d = s.startedAt
let title: String
- if cal.isDateInToday(d) { title = "今天" }
- else if cal.isDateInYesterday(d) { title = "昨天" }
- else if cal.isDate(d, equalTo: Date(), toGranularity: .weekOfYear) { title = "本周" }
- else if cal.isDate(d, equalTo: Date(), toGranularity: .year) { f.dateFormat = "M月"; title = f.string(from: d) }
- else { f.dateFormat = "yyyy年M月"; title = f.string(from: d) }
+ if cal.isDateInToday(d) { title = L("今天") }
+ else if cal.isDateInYesterday(d) { title = L("昨天") }
+ else if cal.isDate(d, equalTo: Date(), toGranularity: .weekOfYear) { title = L("本周") }
+ else if cal.isDate(d, equalTo: Date(), toGranularity: .year) { title = dateText(d, "MMMM") }
+ else { title = dateText(d, "yMMMM") }
if out.last?.title == title { out[out.count - 1].sessions.append(s) } else { out.append((title, [s])) }
}
return out
@@ -384,19 +401,17 @@ struct MainWindowView: View {
}
private func meta(_ s: Session, live: Bool) -> String {
- let f = DateFormatter()
- f.locale = Locale(identifier: "zh_CN")
let cal = Calendar.current
- f.dateFormat = cal.isDateInToday(s.startedAt) || cal.isDateInYesterday(s.startedAt) ? "HH:mm"
- : cal.isDate(s.startedAt, equalTo: Date(), toGranularity: .weekOfYear) ? "EEE HH:mm" : "M月d日 HH:mm"
- if live { return "正在记录 · \(f.string(from: s.startedAt)) 起 · \(s.lines.count) 句" }
- return [f.string(from: s.startedAt), Self.length(s), Self.pair(s, short: true)].compactMap { $0 }.joined(separator: " · ")
+ let when = dateText(s.startedAt, cal.isDateInToday(s.startedAt) || cal.isDateInYesterday(s.startedAt) ? "HHmm"
+ : cal.isDate(s.startedAt, equalTo: Date(), toGranularity: .weekOfYear) ? "EEEHHmm" : "MMMdHHmm")
+ if live { return L("正在记录 · \(when) 起 · \(s.lines.count) 句") }
+ return [when, Self.length(s), Self.pair(s, short: true)].compactMap { $0 }.joined(separator: " · ")
}
static func length(_ s: Session) -> String {
let mins = Int(s.duration / 60)
- if mins < 1 { return "不到 1 分钟" }
- return mins < 60 ? "\(mins) 分钟" : mins % 60 == 0 ? "\(mins / 60) 小时" : "\(mins / 60) 小时 \(mins % 60) 分"
+ if mins < 1 { return L("不到 1 分钟") }
+ return mins < 60 ? L("\(mins) 分钟") : mins % 60 == 0 ? L("\(mins / 60) 小时") : L("\(mins / 60) 小时 \(mins % 60) 分")
}
/// "英 → 中" (short) or "英语 → 中文", from the most common pair among the lines.
@@ -406,10 +421,11 @@ struct MainWindowView: View {
let p = top.split(separator: "|").map(String.init)
guard p.count == 2, p[0] != p[1] else { return nil }
func name(_ c: String) -> String {
- let names = ["en": "英语", "ja": "日语", "zh-CN": "中文", "zh-TW": "繁中", "ko": "韩语",
- "es": "西语", "fr": "法语", "de": "德语", "pt": "葡语"]
+ let names = ["en": L("英语"), "ja": L("日语"), "zh-CN": L("中文"), "zh-TW": L("繁中"), "ko": L("韩语"),
+ "es": L("西语"), "fr": L("法语"), "de": L("德语"), "pt": L("葡语")]
guard let n = names[c] else { return c.uppercased() }
- return short ? String(n.prefix(1)) : n
+ guard short else { return n }
+ return uiIsChinese ? String(n.prefix(1)) : c == "zh-TW" ? "ZH-TW" : String(c.prefix(2)).uppercased()
}
return "\(name(p[0])) → \(name(p[1]))"
}
@@ -424,8 +440,8 @@ struct MainWindowView: View {
HStack(spacing: 10) {
LogoTile(size: 28).opacity(model.running ? 1 : 0.5)
VStack(alignment: .leading, spacing: 1) {
- Text(model.running ? "正在听" : "已暂停").font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.ink)
- Text(model.running ? model.summary : "打开开关开始听").font(.system(size: 11)).foregroundStyle(Palette.secondary)
+ Text(model.running ? L("正在听") : L("已暂停")).font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.ink)
+ Text(model.running ? model.summary : L("打开开关开始听")).font(.system(size: 11)).foregroundStyle(Palette.secondary)
.lineLimit(1)
}
Spacer(minLength: 4)
@@ -455,7 +471,7 @@ struct MainWindowView: View {
.frame(maxWidth: .infinity)
}
.overlay {
- Text(s.id == store.liveID ? "正在听,说话的内容会出现在这里" : "这场会议没有记录到内容")
+ Text(s.id == store.liveID ? L("正在听,说话的内容会出现在这里") : L("这场会议没有记录到内容"))
.font(.system(size: 13)).foregroundStyle(Palette.secondary)
}
} else if tab == "notes" {
@@ -482,8 +498,8 @@ struct MainWindowView: View {
private func toolbar(_ s: Session) -> some View {
HStack(spacing: 4) {
- tabButton("纪要", id: "notes")
- tabButton("文字记录", id: "transcript", count: s.lines.count)
+ tabButton(L("纪要"), id: "notes")
+ tabButton(L("文字记录"), id: "transcript", count: s.lines.count)
Spacer()
if tab == "transcript" {
Picker("显示", selection: $view) {
@@ -550,12 +566,12 @@ struct MainWindowView: View {
titleDraft = ""
}
HStack(spacing: 8) {
- if live { Tag("正在记录", live: true) }
+ if live { Tag(L("正在记录"), live: true) }
chip(Self.length(s))
- chip("\(s.lines.count) 句")
+ chip(L("\(s.lines.count) 句"))
if let p = Self.pair(s, short: false) { chip(p) }
if let n = (live ? model.notes.notes : s.notes), !n.isEmpty {
- if n.final { Tag("完整版纪要", live: true) } else { chip("速记版纪要") }
+ if n.final { Tag(L("完整版纪要"), live: true) } else { chip(L("速记版纪要")) }
}
}
}
@@ -570,13 +586,9 @@ struct MainWindowView: View {
}
private func dateLine(_ s: Session, live: Bool) -> String {
- let f = DateFormatter()
- f.locale = Locale(identifier: "zh_CN")
- f.dateFormat = "M月d日 EEE HH:mm"
- let start = f.string(from: s.startedAt)
- guard !live, let end = s.endedAt else { return live ? "\(start) 起" : start }
- f.dateFormat = "HH:mm"
- return "\(start) – \(f.string(from: end))"
+ let start = dateText(s.startedAt, "MMMdEEEHHmm")
+ guard !live, let end = s.endedAt else { return live ? L("\(start) 起") : start }
+ return "\(start) – \(dateText(end, "HHmm"))"
}
private func transcript(_ s: Session) -> some View {
@@ -612,7 +624,7 @@ struct MainWindowView: View {
.font(.system(size: 12).monospacedDigit()).foregroundStyle(Palette.tertiary)
.frame(width: 52, alignment: .leading).padding(.top, 1)
VStack(alignment: .leading, spacing: 5) {
- Text(me ? "你" : "对方").font(.system(size: 11, weight: .semibold))
+ Text(me ? L("你") : L("对方")).font(.system(size: 11, weight: .semibold))
.foregroundStyle(me ? Palette.accentInk : Palette.secondary)
if view != "dst" {
Text(l.src)
@@ -622,7 +634,7 @@ struct MainWindowView: View {
.textSelection(.enabled)
}
if view != "src" {
- Text(l.dst ?? "翻译中…")
+ Text(l.dst ?? L("翻译中…"))
.font(.system(size: 15)).lineSpacing(3)
.foregroundStyle(l.dst == nil ? Palette.tertiary : Palette.ink)
.textSelection(.enabled)
@@ -661,20 +673,20 @@ struct SessionNotesView: View {
NotesGeneratingView(heard: session.lines.count)
} else {
VStack(alignment: .leading, spacing: 10) {
- Text(generating ? "正在整理纪要…" : live ? "纪要会在会议进行中自动生成" : "这场会议还没有纪要")
+ Text(generating ? L("正在整理纪要…") : live ? L("纪要会在会议进行中自动生成") : L("这场会议还没有纪要"))
.font(.system(size: 15, weight: .bold))
- Text(ling.hasKey ? "使用 Ling 将文字记录整理为总结、议题、结论和人名,约需半分钟。"
- : "前往 设置 › AI 服务 填入 Ling 的 API key 后即可生成。")
+ Text(ling.hasKey ? L("使用 Ling 将文字记录整理为总结、议题、结论和人名,约需半分钟。")
+ : L("前往 设置 › AI 服务 填入 Ling 的 API key 后即可生成。"))
.font(.system(size: 13)).foregroundStyle(Palette.secondary)
if !live {
HStack(spacing: 8) {
if ling.hasKey {
- SoftButton(generating ? "正在生成…" : "生成纪要", dark: true) {
+ SoftButton(generating ? L("正在生成…") : L("生成纪要"), dark: true) {
engine.generate(for: session.id)
}
.disabled(generating)
} else {
- SoftButton("去填 key", dark: true) { model.openSettings(.ai) }
+ SoftButton(L("去填 key"), dark: true) { model.openSettings(.ai) }
}
}
}
diff --git a/Sources/LiveSubs/VirtualMic.swift b/Sources/LiveSubs/VirtualMic.swift
index 37d5b92..725a6b6 100644
--- a/Sources/LiveSubs/VirtualMic.swift
+++ b/Sources/LiveSubs/VirtualMic.swift
@@ -73,7 +73,7 @@ final class VirtualMicInstaller: ObservableObject {
state = .installing
try? await Task.sleep(nanoseconds: 200_000_000) // let "安装中" show before the dialog
let cmd = "/usr/sbin/installer -pkg " + shellQuote(pkg.path) + " -target / && " + Self.restartAudio
- guard runPrivileged(cmd, prompt: "\(appDisplayName)要安装虚拟麦克风,让会议里的人听到你的翻译。") else { return }
+ guard runPrivileged(cmd, prompt: L("\(appDisplayName)要安装虚拟麦克风,让会议里的人听到你的翻译。")) else { return }
state = .reloading
await waitForDevice(onLoaded: onInstalled)
}
@@ -85,7 +85,7 @@ final class VirtualMicInstaller: ObservableObject {
Task {
state = .reloading
try? await Task.sleep(nanoseconds: 200_000_000)
- guard runPrivileged(Self.restartAudio, prompt: "\(appDisplayName)要让系统认出虚拟麦克风,声音会断约 1 秒。") else { return }
+ guard runPrivileged(Self.restartAudio, prompt: L("\(appDisplayName)要让系统认出虚拟麦克风,声音会断约 1 秒。")) else { return }
await waitForDevice(onLoaded: nil)
}
}
@@ -99,7 +99,7 @@ final class VirtualMicInstaller: ObservableObject {
_ = await AVCaptureDevice.requestAccess(for: .audio)
}
guard AVCaptureDevice.authorizationStatus(for: .audio) == .authorized else {
- test = .init(heard: false, text: "", levels: [], problem: "试音要用麦克风权限,请在系统设置里允许\(appDisplayName)")
+ test = .init(heard: false, text: "", levels: [], problem: L("试音要用麦克风权限,请在系统设置里允许\(appDisplayName)"))
state = .idle
return
}
@@ -122,13 +122,13 @@ final class VirtualMicInstaller: ObservableObject {
do {
let (tmp, response) = try await URLSession.shared.download(from: Self.packageURL)
guard (response as? HTTPURLResponse)?.statusCode == 200 else {
- state = .failed("下载失败,请检查网络")
+ state = .failed(L("下载失败,请检查网络"))
return nil
}
let digest = SHA256.hash(data: try Data(contentsOf: tmp)).map { String(format: "%02x", $0) }.joined()
guard digest == Self.packageSHA256 else {
debugLog("virtual mic: checksum mismatch \(digest)")
- state = .failed("安装包校验未通过,已中止安装")
+ state = .failed(L("安装包校验未通过,已中止安装"))
return nil
}
let dir = FileManager.default.temporaryDirectory.appendingPathComponent("LiveSubsMic", isDirectory: true)
@@ -140,7 +140,7 @@ final class VirtualMicInstaller: ObservableObject {
return pkg
} catch {
debugLog("virtual mic: download error \(error)")
- state = .failed("下载失败,请检查网络")
+ state = .failed(L("下载失败,请检查网络"))
return nil
}
}
@@ -153,7 +153,7 @@ final class VirtualMicInstaller: ObservableObject {
guard let errorInfo else { return true }
let code = errorInfo[NSAppleScript.errorNumber] as? Int ?? 0
debugLog("virtual mic: privileged command error \(errorInfo)")
- state = code == -128 ? .idle : .failed("安装未完成,请再试一次")
+ state = code == -128 ? .idle : .failed(L("安装未完成,请再试一次"))
return false
}
@@ -163,7 +163,7 @@ final class VirtualMicInstaller: ObservableObject {
}
generation += 1
guard isLoaded else {
- state = .failed(isOnDisk ? "系统还没认出它,点“让系统认出它”再试一次" : "安装未完成,请再试一次")
+ state = .failed(isOnDisk ? L("系统还没认出它,点“让系统认出它”再试一次") : L("安装未完成,请再试一次"))
return
}
debugLog("virtual mic: loaded")
@@ -190,7 +190,7 @@ enum LoopbackTest {
static func run(device: OutputDevice, phrase: String, play: @escaping () async -> Void) async -> VirtualMicInstaller.TestResult {
let recorder = LoopbackRecorder()
guard recorder.start(deviceID: device.id) else {
- return .init(heard: false, text: "", levels: [], problem: "打不开虚拟麦克风,点“让系统认出它”后再试")
+ return .init(heard: false, text: "", levels: [], problem: L("打不开虚拟麦克风,点“让系统认出它”后再试"))
}
try? await Task.sleep(nanoseconds: 150_000_000)
await play()
@@ -202,7 +202,7 @@ enum LoopbackTest {
let text = loud ? await transcribe(buffers, locale: "en-US") : ""
// Any real signal counts; the transcript is shown so people can judge it themselves.
return .init(heard: loud, text: text, levels: levels,
- problem: loud ? nil : buffers.isEmpty ? "虚拟麦克风未收到声音,请再试一次" : nil)
+ problem: loud ? nil : buffers.isEmpty ? L("虚拟麦克风未收到声音,请再试一次") : nil)
}
static func transcribe(_ buffers: [AVAudioPCMBuffer], locale: String) async -> String {
diff --git a/Sources/LiveSubs/VoicePicker.swift b/Sources/LiveSubs/VoicePicker.swift
index 2fbca7d..3f19930 100644
--- a/Sources/LiveSubs/VoicePicker.swift
+++ b/Sources/LiveSubs/VoicePicker.swift
@@ -55,7 +55,7 @@ struct VoiceSection: View {
Button(l.title) { tab = l.key }
}
} label: {
- Text(Self.mainTabs.contains(current) ? "更多…" : title(current))
+ Text(Self.mainTabs.contains(current) ? L("更多…") : title(current))
.font(.system(size: 12, weight: Self.mainTabs.contains(current) ? .regular : .semibold))
.foregroundStyle(Self.mainTabs.contains(current) ? Palette.secondary : Palette.ink)
.padding(.horizontal, 10).frame(height: 24)
@@ -95,7 +95,7 @@ struct VoiceSection: View {
VStack(alignment: .leading, spacing: 4) {
Text(v.name).font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ink).lineLimit(1)
HStack(spacing: 4) {
- ForEach(usable ? v.tags : [v.tags.first ?? "", "需要 Ling key"], id: \.self) { tagView($0) }
+ ForEach(usable ? v.tags : [v.tags.first ?? "", L("需要 Ling key")], id: \.self) { tagView($0) }
}
}
Spacer(minLength: 0)
@@ -134,7 +134,7 @@ struct VoiceSection: View {
.buttonStyle(.plain)
.disabled(!enabled || playing)
.help("试听")
- .accessibilityLabel("试听")
+ .accessibilityLabel(L("试听"))
}
@ViewBuilder
@@ -153,14 +153,15 @@ struct VoiceSection: View {
}
VStack(alignment: .leading, spacing: 3) {
Text("我自己的声音").font(.system(size: 13, weight: .semibold))
- Text(has ? "已录好 · \(Int(VoiceReference.duration.rounded())) 秒 · \(cloneNote)"
- : "录制 15 秒原声,让对方听到你的音色;说外语时会保留你的口音,延迟约 3 秒")
+ Text(has ? L("已录好 · \(Int(VoiceReference.duration.rounded())) 秒 · \(cloneNote)")
+ : L("录制 15 秒原声,让对方听到你的音色;说外语时会保留你的口音,延迟约 3 秒"))
.font(.system(size: 12)).foregroundStyle(Palette.tertiary).lineLimit(2)
+ .fixedSize(horizontal: false, vertical: true)
}
Spacer(minLength: 6)
if has {
if !selected {
- SoftButton("用这个") { model.setVoice("clone", for: language) }.disabled(!ling.usable)
+ SoftButton(L("用这个")) { model.setVoice("clone", for: language) }.disabled(!ling.usable)
}
Button("重录") { recording = true }.buttonStyle(.plain).font(.system(size: 12)).foregroundStyle(Palette.secondary)
Button("删除") {
@@ -170,7 +171,7 @@ struct VoiceSection: View {
}
.buttonStyle(.plain).font(.system(size: 12)).foregroundStyle(Palette.secondary)
} else {
- SoftButton("录制") { recording = true }
+ SoftButton(L("录制")) { recording = true }
}
}
.padding(12)
@@ -180,13 +181,13 @@ struct VoiceSection: View {
private var cloneNote: String {
let own = VoiceCatalog.key(for: settings.speakFromLang.locale)
- return own == current ? "说\(title(current))最像你,晚约 3 秒" : "说\(title(current))会带你的口音,晚约 3 秒"
+ return own == current ? L("说\(title(current))最像你,晚约 3 秒") : L("说\(title(current))会带你的口音,晚约 3 秒")
}
private var footnote: String {
- if !ling.usable { return "未填写 Ling key 时仅可使用系统声音;填入 key 后可使用 Ming 语音或克隆你自己的声音。" }
- if chosen == "clone" { return "录音仅保存在本机,每次发言时随文字发送给 Ling 合成语音;Ling 不可用时自动切回系统声音。" }
- return "Ming 语音需使用 Ling key,延迟约 1.5 秒;Ling 不可用时自动切回系统声音。"
+ if !ling.usable { return L("未填写 Ling key 时仅可使用系统声音;填入 key 后可使用 Ming 语音或克隆你自己的声音。") }
+ if chosen == "clone" { return L("录音仅保存在本机,每次发言时随文字发送给 Ling 合成语音;Ling 不可用时自动切回系统声音。") }
+ return L("Ming 语音需使用 Ling key,延迟约 1.5 秒;Ling 不可用时自动切回系统声音。")
}
}
@@ -242,16 +243,16 @@ struct VoiceCloneSheet: View {
.toggleStyle(.checkbox)
.disabled(recorder.phase == .recording)
HStack {
- SoftButton("取消") { recorder.cancel(); onDone(false) }
+ SoftButton(L("取消")) { recorder.cancel(); onDone(false) }
Spacer()
switch recorder.phase {
case .recording:
- SoftButton("读完了", dark: true) { recorder.finish() }
+ SoftButton(L("读完了"), dark: true) { recorder.finish() }
.disabled(recorder.seconds < VoiceRecorder.minSeconds)
case .checking:
HStack(spacing: 8) { Spinner(size: 14); Text("正在听写…").font(.system(size: 12)).foregroundStyle(Palette.secondary) }
default:
- SoftButton(recorder.phase == .idle ? "开始录" : "再录一次", dark: true) {
+ SoftButton(recorder.phase == .idle ? L("开始录") : L("再录一次"), dark: true) {
recorder.start(locale: ownLocale)
}
.disabled(!consent)
@@ -291,12 +292,12 @@ struct VoiceCloneSheet: View {
.font(.system(size: 13)).foregroundStyle(Palette.secondary)
}
VStack(spacing: 0) {
- row(icon: playing ? "stop.fill" : "play.fill", accent: false, title: "你的原声", detail: recorder.transcript) {
+ row(icon: playing ? "stop.fill" : "play.fill", accent: false, title: L("你的原声"), detail: recorder.transcript) {
togglePlayOriginal()
}
Divider()
row(icon: clonePlaying ? nil : "play.fill", accent: true,
- title: "用你的声音说\(targetTitle)", detail: VoiceCatalog.sample(for: language), tag: "对方会听到这个") {
+ title: L("用你的声音说\(targetTitle)"), detail: VoiceCatalog.sample(for: language), tag: L("对方会听到这个")) {
playClone()
}
}
@@ -307,9 +308,9 @@ struct VoiceCloneSheet: View {
Text("听起来不像或有杂音?换个安静的地方重录一次。录音仅保存在本机,可随时删除。")
.font(.system(size: 12)).foregroundStyle(Palette.tertiary)
HStack {
- SoftButton("重录") { player?.stop(); recorder.start(locale: ownLocale) }
+ SoftButton(L("重录")) { player?.stop(); recorder.start(locale: ownLocale) }
Spacer()
- SoftButton("用这个声音", dark: true) { save() }
+ SoftButton(L("用这个声音"), dark: true) { save() }
}
}
}
diff --git a/Sources/LiveSubs/Voices.swift b/Sources/LiveSubs/Voices.swift
index 2d4a96c..fe09321 100644
--- a/Sources/LiveSubs/Voices.swift
+++ b/Sources/LiveSubs/Voices.swift
@@ -48,13 +48,13 @@ enum VoiceCatalog {
}
switch key(for: language) {
case "en":
- return [v("US_Emma", "Emma", ["女", "美式", "自然对话"]), v("UK_George", "George", ["男", "英式", "稳重"]),
- v("UK_Charlotte", "Charlotte", ["女", "英式", "平稳"])]
+ return [v("US_Emma", "Emma", [L("女"), L("美式"), L("自然对话")]), v("UK_George", "George", [L("男"), L("英式"), L("稳重")]),
+ v("UK_Charlotte", "Charlotte", [L("女"), L("英式"), L("平稳")])]
case "zh":
- return [v("灵小雅", "小雅", ["女", "清亮", "播报"]), v("灵小棠", "小棠", ["女", "温和", "沉稳"]),
- v("灵小锋", "小锋", ["男", "温暖", "亲切"]), v("灵卓然", "卓然", ["男", "沉着", "清楚"])]
+ return [v("灵小雅", "小雅", [L("女"), L("清亮"), L("播报")]), v("灵小棠", "小棠", [L("女"), L("温和"), L("沉稳")]),
+ v("灵小锋", "小锋", [L("男"), L("温暖"), L("亲切")]), v("灵卓然", "卓然", [L("男"), L("沉着"), L("清楚")])]
case "ja", "ko", "de", "fr", "es":
- return [v("US_Emma", "Emma", ["女", "Ming"]), v("UK_George", "George", ["男", "Ming"])]
+ return [v("US_Emma", "Emma", [L("女"), "Ming"]), v("UK_George", "George", [L("男"), "Ming"])]
default:
return []
}
@@ -71,9 +71,9 @@ enum VoiceCatalog {
var out: [VoiceOption] = []
for gender in [AVSpeechSynthesisVoiceGender.female, .male] {
guard let best = all.filter({ $0.gender == gender }).max(by: { $0.quality.rawValue < $1.quality.rawValue }) else { continue }
- let quality = best.quality == .premium ? "高品质" : best.quality == .enhanced ? "增强" : "标准"
+ let quality = best.quality == .premium ? L("高品质") : best.quality == .enhanced ? L("增强") : L("标准")
out.append(VoiceOption(id: "system:\(best.identifier)", name: best.name,
- tags: [gender == .female ? "女" : "男", "本机", quality], kind: .system(best.identifier)))
+ tags: [gender == .female ? L("女") : L("男"), L("本机"), quality], kind: .system(best.identifier)))
}
return out
}
@@ -85,7 +85,7 @@ enum VoiceCatalog {
(hasKey ? ming(for: language).first : nil)?.id ?? system(for: language).first?.id
}
- static let cloneOption = VoiceOption(id: "clone", name: "我自己的声音", tags: [], kind: .clone)
+ static let cloneOption = VoiceOption(id: "clone", name: L("我自己的声音"), tags: [], kind: .clone)
/// A short line to try a voice with, in the language it will speak.
static func sample(for language: String) -> String {
@@ -195,7 +195,7 @@ final class VoiceRecorder: ObservableObject {
guard inFormat.sampleRate > 0,
let f = try? AVAudioFile(forWriting: url, settings: format.settings, commonFormat: .pcmFormatInt16, interleaved: true),
let conv = AVAudioConverter(from: inFormat, to: format) else {
- phase = .failed("麦克风没收到声音,请检查麦克风权限")
+ phase = .failed(L("麦克风没收到声音,请检查麦克风权限"))
return
}
file = f
@@ -223,7 +223,7 @@ final class VoiceRecorder: ObservableObject {
try engine.start()
} catch {
input.removeTap(onBus: 0)
- phase = .failed("无法打开麦克风:\(error.localizedDescription)")
+ phase = .failed(L("无法打开麦克风:\(error.localizedDescription)"))
return
}
started = Date()
@@ -246,7 +246,7 @@ final class VoiceRecorder: ObservableObject {
guard phase == .recording else { return }
stopEngine()
guard seconds >= Self.minSeconds else {
- phase = .failed("录音太短了,请至少朗读 \(Int(Self.minSeconds)) 秒")
+ phase = .failed(L("录音太短了,请至少朗读 \(Int(Self.minSeconds)) 秒"))
return
}
phase = .checking
@@ -254,7 +254,7 @@ final class VoiceRecorder: ObservableObject {
Task {
let text = await Self.transcribe(url, locale: locale)
self.transcript = text
- self.phase = text.count >= 6 ? .ready : .failed("没听清录音内容,请换个安静的地方再录一次")
+ self.phase = text.count >= 6 ? .ready : .failed(L("没听清录音内容,请换个安静的地方再录一次"))
}
}
diff --git a/scripts/build.sh b/scripts/build.sh
index 979c3cf..7ff038c 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -19,6 +19,8 @@ cp "$BIN/LiveSubs" "$APP/Contents/MacOS/Cicada"
cp Resources/Info.plist "$APP/Contents/Info.plist"
cp Resources/sample/sample.mp4 Resources/sample/sample.m4a "$APP/Contents/Resources/"
cp -R Resources/zh-Hans.lproj Resources/en.lproj "$APP/Contents/Resources/"
+# Traditional Chinese systems get the Chinese UI rather than English (there is no zh-Hant translation).
+cp -R Resources/zh-Hans.lproj "$APP/Contents/Resources/zh-Hant.lproj"
PLIST="$APP/Contents/Info.plist"
if [[ "${RELEASE:-}" != 1 ]]; then
@@ -27,8 +29,9 @@ if [[ "${RELEASE:-}" != 1 ]]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier com.wquguru.cicada.dev" \
-c "Set :CFBundleName Cicada Dev" -c "Set :CFBundleDisplayName Cicada Dev" \
-c "Add :LiveSubsDev string $STAMP" "$PLIST"
- printf 'CFBundleName = "知了 Dev";\nCFBundleDisplayName = "知了 Dev";\n' > "$APP/Contents/Resources/zh-Hans.lproj/InfoPlist.strings"
- printf 'CFBundleName = "Cicada Dev";\nCFBundleDisplayName = "Cicada Dev";\n' > "$APP/Contents/Resources/en.lproj/InfoPlist.strings"
+ # Only the two name lines change: the usage descriptions in the same files stay.
+ sed -i '' -E 's/^(CFBundle(Display)?Name = ")([^"]*)";/\1\3 Dev";/' \
+ "$APP"/Contents/Resources/*.lproj/InfoPlist.strings
fi
if [[ -n "${BUILD_NUMBER:-}" ]]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD_NUMBER" "$PLIST"
diff --git a/scripts/strings.py b/scripts/strings.py
new file mode 100755
index 0000000..acd27be
--- /dev/null
+++ b/scripts/strings.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python3
+"""UI strings: Chinese source text is the key, Resources/en.lproj/Localizable.strings has the English.
+
+ python3 scripts/strings.py # check: every key in the code has an English entry
+ python3 scripts/strings.py --write # also add missing keys (value = TODO) and rewrite zh-Hans
+
+Keys come from the compiler (-emit-localized-strings), so interpolations are exactly the format
+keys the app looks up ("已听到 %lld 句"). zh-Hans/Localizable.strings maps every key to itself:
+the development region is English, so without it Chinese systems would fall back to English.
+English plurals live in en.lproj/Localizable.stringsdict.
+"""
+import glob, json, os, re, subprocess, sys, tempfile
+
+ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+EN = os.path.join(ROOT, "Resources/en.lproj/Localizable.strings")
+ZH = os.path.join(ROOT, "Resources/zh-Hans.lproj/Localizable.strings")
+DICT = os.path.join(ROOT, "Resources/en.lproj/Localizable.stringsdict")
+CJK = re.compile(r"[\u4e00-\u9fff]")
+
+
+def code_keys():
+ out = tempfile.mkdtemp()
+ subprocess.run(["swift", "build", "--product", "LiveSubs", "-Xswiftc", "-emit-localized-strings",
+ "-Xswiftc", "-emit-localized-strings-path", "-Xswiftc", out],
+ cwd=ROOT, check=True, stdout=subprocess.DEVNULL)
+ keys = {}
+ for f in sorted(glob.glob(os.path.join(out, "*.stringsdata"))):
+ for entries in json.load(open(f))["tables"].values():
+ for e in entries:
+ if CJK.search(e["key"]): # "%@ · %@" and the like need no translation
+ keys.setdefault(e["key"], os.path.basename(f).split(".")[0])
+ return keys
+
+
+def load(path):
+ if not os.path.exists(path):
+ return {}
+ return json.loads(subprocess.check_output(["plutil", "-convert", "json", "-o", "-", path]))
+
+
+def esc(s):
+ return s.replace("\\", "\\\\").replace('"', '\\"').replace("\n", "\\n")
+
+
+def write(path, pairs):
+ lines, last = [], None
+ for k, v, group in pairs:
+ if group != last:
+ lines.append(f"\n/* {group} */")
+ last = group
+ lines.append(f'"{esc(k)}" = "{esc(v)}";')
+ open(path, "w").write("\n".join(lines).lstrip() + "\n")
+
+
+def main():
+ keys = code_keys()
+ en = load(EN)
+ plurals = load(DICT)
+ missing = [k for k in keys if k not in en]
+ unused = [k for k in en if k not in keys]
+ todo = [k for k, v in en.items() if v == "TODO"]
+ for k in missing: print(f"missing {keys[k]}: {k}")
+ for k in unused: print(f"unused {k}")
+ for k in todo: print(f"todo {k}")
+ for k in plurals:
+ if k not in keys: print(f"unused plural {k}")
+ if "--write" in sys.argv:
+ write(EN, [(k, en.get(k, "TODO"), g) for k, g in keys.items()])
+ write(ZH, [(k, k, g) for k, g in keys.items()])
+ for p in (EN, ZH, DICT):
+ if os.path.exists(p):
+ subprocess.run(["plutil", "-lint", "-s", p], check=True)
+ print(f"{len(keys)} keys, {len(missing)} missing, {len(unused)} unused, {len(todo)} TODO")
+ sys.exit(1 if (missing or todo) and "--write" not in sys.argv else 0)
+
+
+main()
diff --git a/site/changelog.json b/site/changelog.json
index f2fc246..f9509f9 100644
--- a/site/changelog.json
+++ b/site/changelog.json
@@ -6,6 +6,11 @@
"summary": "这一版让知了从“实时字幕”变成完整的会议助手:边开会边写纪要,同声传译可以用更自然的声音说出去,虚拟麦克风装完能当场试音。",
"image": null,
"items": [
+ {
+ "kind": "new",
+ "title": "英文界面。",
+ "text": "菜单、设置、菜单栏面板、纪要窗口、会议记录、新手引导、提示框、导出文件和权限说明都会跟随 macOS 的系统语言:中文系统(含繁体)显示中文,其他语言显示英文。纪要内容本身仍按纪要语言来写。"
+ },
{
"kind": "new",
"title": "会议自动命名。",
@@ -110,6 +115,41 @@
"kind": "improved",
"title": "会议记录窗口像读文档一样。",
"text": "会议按今天、昨天、本周、月份分组;左下角能看到是否在听,开关和设置也在这里;每场会议是一页:日期、大标题、时长和语言,总结放在最前面,接着是带时间的议题、结论和待办。⌘F 直接搜索。"
+ },
+ {
+ "kind": "fixed",
+ "title": "会议开头几句没记下来。",
+ "text": "自动识别语言时,确认语言之前说的话(通常是开头 2–5 秒)只显示在字幕里,没有进会议记录和纪要;现在确认语言后会连同译文和时间一起补记。"
+ },
+ {
+ "kind": "fixed",
+ "title": "强制退出后录音打不开。",
+ "text": "会议中途强制退出或崩溃,这场的录音文件就打不开;现在录音能挺过意外退出,下次启动时自动整理成 .m4a。"
+ },
+ {
+ "kind": "fixed",
+ "title": "纪要语言改了没生效。",
+ "text": "纪要正在更新时改纪要语言,纪要会停在原来的语言;现在会接着用新语言重写。"
+ },
+ {
+ "kind": "fixed",
+ "title": "要点时间往后跑。",
+ "text": "同一个要点后来又被提到,时间会跳到后一次;现在保留第一次说到的时间。"
+ },
+ {
+ "kind": "fixed",
+ "title": "填错 key 没有提示。",
+ "text": "填入 Ling 不认的 key 后,纪要窗口仍提示“需要 API key”;现在会说明 key 无效。"
+ },
+ {
+ "kind": "fixed",
+ "title": "快捷键录成原来的被拒。",
+ "text": "重新录入当前正在用的快捷键,会被误判为“已被其他应用占用”。"
+ },
+ {
+ "kind": "fixed",
+ "title": "英文界面文字被截断。",
+ "text": "设置里的语言路线、菜单栏面板、纪要窗口状态行和收起小卡等处的英文不再被截断。"
}
]
},