Control a real USB-connected iPhone from Linux (no Mac, no paid developer account) and expose it to AI agents as MCP tools
Rust ai-agentautomationclaudeclaude-codedockeriosiphonelinuxmcpmcp-servermodel-context-protocolrustwebdriveragent
feat(cli): English CLI output, help, status and doctor (#32)
TheSalaty4f1f59d6ef37
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1e57618..98b6d75 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,8 +8,8 @@ All notable changes to this project are documented here. The format is based on### Added-- English: `IPHONE_CONTROL_LANG=en` switches the MCP server instructions, tool descriptions and tool results to English. The default stays Simplified Chinese, so nothing changes unless you set it.-- The MCP server sends its language with each request and the daemon answers in it; requests from older clients carry none and get Chinese as before, so mixed versions during an upgrade keep working.+- English: `IPHONE_CONTROL_LANG=en` switches the MCP server instructions, tool descriptions, tool results, CLI output and help, and `status`/`doctor` to English. The default stays Simplified Chinese, so nothing changes unless you set it.+- The MCP server and the CLI send their language with each request and the daemon answers in it; requests from older clients carry none and get Chinese as before, so mixed versions during an upgrade keep working. `mcp-config` includes the setting when English is on.- Text responses carry an optional `outcome` (`tapped_nothing`, `alert_reported`), so the MCP server no longer reads result text to stop a batch after a missed tap or to skip the extra alert check. Responses without it (older daemons) are still recognised by their Chinese prefixes.### Fixeddiff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.mdindex 107d8b4..fa81ebd 100644--- a/CHANGELOG.zh-CN.md+++ b/CHANGELOG.zh-CN.md@@ -8,8 +8,8 @@### 新增-- 英文界面:设 `IPHONE_CONTROL_LANG=en` 后,MCP 服务说明、工具说明和工具结果改成英文。默认仍是简体中文,不设就没有任何变化。-- MCP 在每个请求里带上自己的语言,守护进程按它回答;旧版本客户端的请求不带语言,照旧用中文,升级过程中新旧版本混用也不受影响。+- 英文界面:设 `IPHONE_CONTROL_LANG=en` 后,MCP 服务说明、工具说明、工具结果、命令行输出和帮助、`status`/`doctor` 改成英文。默认仍是简体中文,不设就没有任何变化。+- MCP 和命令行在每个请求里带上自己的语言,守护进程按它回答;旧版本客户端的请求不带语言,照旧用中文,升级过程中新旧版本混用也不受影响。开着英文时 `mcp-config` 会把这个设置带上。- 文字响应带可选的 `outcome`(`tapped_nothing`、`alert_reported`),MCP 端据此在没点到时停下批量、跳过多余的弹窗检查,不再从结果文字里认;没有这个字段的响应(旧版本守护进程)照旧按中文开头认。### 修复diff --git a/Cargo.lock b/Cargo.lockindex 61eef55..ff3d699 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2015,6 +2015,7 @@ dependencies = [name = "ictl-sign"version = "0.1.4"dependencies = [+ "ictl-l10n","plist","plume_core","plume_store",@@ -2257,6 +2258,7 @@ dependencies = ["clap","ictl-daemon","ictl-device",+ "ictl-l10n","ictl-mcp","ictl-sign","ictl-wda",diff --git a/apps/iphone-control/Cargo.toml b/apps/iphone-control/Cargo.tomlindex 58f49f8..0c8c38b 100644--- a/apps/iphone-control/Cargo.toml+++ b/apps/iphone-control/Cargo.toml@@ -10,6 +10,7 @@ homepage.workspace = truedescription = "iphone-control 命令行入口"[dependencies]+ictl-l10n.workspace = trueictl-daemon.workspace = trueictl-device.workspace = trueictl-mcp.workspace = truediff --git a/apps/iphone-control/src/debug.rs b/apps/iphone-control/src/debug.rsindex 12d6f33..a144176 100644--- a/apps/iphone-control/src/debug.rs+++ b/apps/iphone-control/src/debug.rs@@ -72,26 +72,33 @@ async fn wait_foreground(wda: &ictl_wda::WdaClient<ictl_wda::http::DeviceTranspofn check(step: &str, t0: Instant, ok: bool, detail: String) -> anyhow::Result<()> {let el = t0.elapsed().as_secs_f64();if ok {- println!("✓ {step}({el:.2}s){detail}");+ println!("{}", ictl_l10n::trf!("✓ {step}({el:.2}s){detail}", "✓ {step} ({el:.2}s){detail}"));Ok(())} else {- println!("✗ {step}({el:.2}s){detail}");- anyhow::bail!("{step} 失败:{detail}")+ println!("{}", ictl_l10n::trf!("✗ {step}({el:.2}s){detail}", "✗ {step} ({el:.2}s){detail}"));+ anyhow::bail!("{}", ictl_l10n::trf!("{step} 失败:{detail}", "{step} failed: {detail}"))}}async fn e2e(device: &Device, bundle_id: &str, out: &std::path::Path) -> anyhow::Result<()> {let t = Instant::now();let mut tunnel = device.open_tunnel().await?;- check("建隧道", t, true, String::new())?;+ check(ictl_l10n::tr!("建隧道", "open tunnel"), t, true, String::new())?;let t = Instant::now();let ddi = tunnel.ddi_mounted().await?;- check("开发者镜像", t, ddi.is_some(), ddi.unwrap_or_else(|| "未挂载(先运行 ddi 子命令)".into()))?;+ check(+ ictl_l10n::tr!("开发者镜像", "developer disk image"),+ t,+ ddi.is_some(),+ ddi.unwrap_or_else(|| {+ ictl_l10n::tr!("未挂载(先运行 ddi 子命令)", "not mounted (run the ddi subcommand first)").into()+ }),+ )?;let t = Instant::now();let (runner, mut wda) = ictl_wda::WdaRunner::start(device.provider(), bundle_id, Duration::from_secs(60)).await?;- check("启动 WDA", t, true, String::new())?;+ check(ictl_l10n::tr!("启动 WDA", "start WDA"), t, true, String::new())?;let r = e2e_with_wda(&mut tunnel, &mut wda, out).await;runner.stop();r@@ -106,22 +113,37 @@ async fn e2e_with_wda(let t = Instant::now();wda.press_button("home").await?;let now = wait_foreground(wda, SPRINGBOARD).await;- check("回主屏", t, now == SPRINGBOARD, format!("前台 {now}"))?;+ check(+ ictl_l10n::tr!("回主屏", "home screen"),+ t,+ now == SPRINGBOARD,+ ictl_l10n::trf!("前台 {now}", "foreground {now}"),+ )?;let t = Instant::now();let png = wda.screenshot_png().await?;std::fs::write(out, &png)?;- check("WDA 截图", t, png.starts_with(b"\x89PNG"), format!("{} 字节 → {}", png.len(), out.display()))?;+ check(+ ictl_l10n::tr!("WDA 截图", "WDA screenshot"),+ t,+ png.starts_with(b"\x89PNG"),+ ictl_l10n::trf!("{} 字节 → {}", "{} bytes → {}", png.len(), out.display()),+ )?;let t = Instant::now();let els = wda.elements().await?;// 系统语言是中文或英文时主屏上「设置」的名字let icon = els.iter().find(|e| matches!(e.label.as_str(), "设置" | "Settings") && e.kind == "Icon").cloned();check(- "读元素",+ ictl_l10n::tr!("读元素", "read elements"),t,icon.is_some(),- format!("{} 个元素;「设置」{}", els.len(), icon.as_ref().map_or("未找到".into(), |e| e.describe())),+ ictl_l10n::trf!(+ "{} 个元素;「设置」{}",+ "{} elements; “Settings” {}",+ els.len(),+ icon.as_ref().map_or(ictl_l10n::tr!("未找到", "not found").into(), |e| e.describe())+ ),)?;let (x, y) = icon.unwrap().center;let (x, y) = (x as f64, y as f64);@@ -129,27 +151,37 @@ async fn e2e_with_wda(let t = Instant::now();wda.tap(x, y).await?;let now = wait_foreground(wda, PREFERENCES).await;- check("WDA 点「设置」", t, now == PREFERENCES, format!("前台 {now}"))?;+ check(+ ictl_l10n::tr!("WDA 点「设置」", "WDA tap “Settings”"),+ t,+ now == PREFERENCES,+ ictl_l10n::trf!("前台 {now}", "foreground {now}"),+ )?;let t = Instant::now();wda.press_button("home").await?;let now = wait_foreground(wda, SPRINGBOARD).await;- check("WDA Home", t, now == SPRINGBOARD, format!("前台 {now}"))?;+ check("WDA Home", t, now == SPRINGBOARD, ictl_l10n::trf!("前台 {now}", "foreground {now}"))?;// HID 路线:同样的点击和 Home,以 WDA 的前台 App 判断是否生效let screen = wda.screen_size().await?;let t = Instant::now();let hid = tunnel.hid(screen).await?;- check("打开 HID 会话", t, true, String::new())?;+ check(ictl_l10n::tr!("打开 HID 会话", "open HID session"), t, true, String::new())?;let r = async {let t = Instant::now();hid.tap(x, y).await?;let now = wait_foreground(wda, PREFERENCES).await;- check("HID 点「设置」", t, now == PREFERENCES, format!("前台 {now}"))?;+ check(+ ictl_l10n::tr!("HID 点「设置」", "HID tap “Settings”"),+ t,+ now == PREFERENCES,+ ictl_l10n::trf!("前台 {now}", "foreground {now}"),+ )?;let t = Instant::now();hid.press(Button::Home).await?;let now = wait_foreground(wda, SPRINGBOARD).await;- check("HID Home", t, now == SPRINGBOARD, format!("前台 {now}"))+ check("HID Home", t, now == SPRINGBOARD, ictl_l10n::trf!("前台 {now}", "foreground {now}"))}.await;// 停掉屏幕媒体流,否则手机端一直挂着@@ -160,18 +192,31 @@ async fn e2e_with_wda(pub async fn run(udid: Option<&str>, args: DebugArgs) -> anyhow::Result<()> {let device = Device::find(udid).await?;let info = device.info().await?;- println!("手机 {} iOS {}", info.product_type, info.product_version);+ println!("{}", ictl_l10n::trf!("手机 {} iOS {}", "Phone {} iOS {}", info.product_type, info.product_version));let screen = ScreenSize { width: args.width, height: args.height };match args.check {Check::Ddi { restore_dir, url } => {let mut t = device.open_tunnel().await?;match t.ddi_mounted().await? {- Some(v) => println!("开发者镜像已挂载 {v}(要测挂载流程,先在手机重启后的未挂载状态下运行)"),+ Some(v) => println!(+ "{}",+ ictl_l10n::trf!(+ "开发者镜像已挂载 {v}(要测挂载流程,先在手机重启后的未挂载状态下运行)",+ "Developer disk image already mounted {v} (to test mounting, run it after a phone reboot while it is unmounted)"+ )+ ),None => {let dir = ictl_device::ddi::ensure_cache(&restore_dir, &url).await?;let t0 = Instant::now();let v = t.mount_ddi(&dir).await?;- println!("挂载成功 {v},耗时 {:.1}s", t0.elapsed().as_secs_f64());+ println!(+ "{}",+ ictl_l10n::trf!(+ "挂载成功 {v},耗时 {:.1}s",+ "Mounted {v} in {:.1}s",+ t0.elapsed().as_secs_f64()+ )+ );}}let t = device.open_tunnel().await?;@@ -182,7 +227,10 @@ pub async fn run(udid: Option<&str>, args: DebugArgs) -> anyhow::Result<()> {let r = async {let hid = t.hid(screen).await?;hid.tap(x, y).await?;- println!("已点 ({x},{y}),3 秒后按 Home");+ println!(+ "{}",+ ictl_l10n::trf!("已点 ({x},{y}),3 秒后按 Home", "Tapped ({x},{y}), pressing Home in 3 seconds")+ );tokio::time::sleep(Duration::from_secs(3)).await;hid.press(Button::Home).await}@@ -190,14 +238,29 @@ pub async fn run(udid: Option<&str>, args: DebugArgs) -> anyhow::Result<()> {// 停掉屏幕媒体流,否则手机端一直挂着t.close().await;r?;- println!("完成:请以截图/肉眼确认是否真的生效");+ println!(+ "{}",+ ictl_l10n::tr!(+ "完成:请以截图/肉眼确认是否真的生效",+ "Done: confirm with a screenshot or by eye that it really worked"+ )+ );}Check::Screenshot { out } => {let mut t = device.open_tunnel().await?;let t0 = Instant::now();let png = t.screenshot_png().await?;std::fs::write(&out, &png)?;- println!("{} 字节,耗时 {:.2}s → {}", png.len(), t0.elapsed().as_secs_f64(), out.display());+ println!(+ "{}",+ ictl_l10n::trf!(+ "{} 字节,耗时 {:.2}s → {}",+ "{} bytes in {:.2}s → {}",+ png.len(),+ t0.elapsed().as_secs_f64(),+ out.display()+ )+ );}Check::Soak { minutes } => {let mut t = device.open_tunnel().await?;@@ -213,37 +276,62 @@ pub async fn run(udid: Option<&str>, args: DebugArgs) -> anyhow::Result<()> {}Err(e) => {fails += 1;- eprintln!("截图失败:{e},重建隧道");+ eprintln!(+ "{}",+ ictl_l10n::trf!("截图失败:{e},重建隧道", "Screenshot failed: {e}, reopening the tunnel")+ );t = device.open_tunnel().await?;}}tokio::time::sleep(Duration::from_secs(2)).await;}- println!("{n} 次成功、{fails} 次失败,共 {:.1} MB,最慢 {worst:.2}s", bytes as f64 / 1e6);+ println!(+ "{}",+ ictl_l10n::trf!(+ "{n} 次成功、{fails} 次失败,共 {:.1} MB,最慢 {worst:.2}s",+ "{n} succeeded, {fails} failed, {:.1} MB total, slowest {worst:.2}s",+ bytes as f64 / 1e6+ )+ );}Check::Wda { bundle_id, timeout } => {let t0 = Instant::now();let (runner, mut wda) =ictl_wda::WdaRunner::start(device.provider(), &bundle_id, Duration::from_secs(timeout)).await?;- println!("WDA 就绪,耗时 {:.1}s", t0.elapsed().as_secs_f64());- println!("屏幕 {:?}", wda.screen_size().await?);+ println!("{}", ictl_l10n::trf!("WDA 就绪,耗时 {:.1}s", "WDA ready in {:.1}s", t0.elapsed().as_secs_f64()));+ println!("{}", ictl_l10n::trf!("屏幕 {:?}", "Screen {:?}", wda.screen_size().await?));let t1 = Instant::now();let xml = wda.source_xml().await?;println!(- "元素树 {} 字节,耗时 {:.2}s,解析出 {} 个元素",- xml.len(),- t1.elapsed().as_secs_f64(),- wda.elements().await?.len()+ "{}",+ ictl_l10n::trf!(+ "元素树 {} 字节,耗时 {:.2}s,解析出 {} 个元素",+ "Element tree {} bytes in {:.2}s, {} elements parsed",+ xml.len(),+ t1.elapsed().as_secs_f64(),+ wda.elements().await?.len()+ ));let t2 = Instant::now();- println!("截图 {} 字节,耗时 {:.2}s", wda.screenshot_png().await?.len(), t2.elapsed().as_secs_f64());+ println!(+ "{}",+ ictl_l10n::trf!(+ "截图 {} 字节,耗时 {:.2}s",+ "Screenshot {} bytes in {:.2}s",+ wda.screenshot_png().await?.len(),+ t2.elapsed().as_secs_f64()+ )+ );runner.stop();- println!("runner 已停止");+ println!("{}", ictl_l10n::tr!("runner 已停止", "runner stopped"));}Check::E2e { bundle_id, out } => {let t0 = Instant::now();e2e(&device, &bundle_id, &out).await?;- println!("全部通过,总耗时 {:.1}s", t0.elapsed().as_secs_f64());+ println!(+ "{}",+ ictl_l10n::trf!("全部通过,总耗时 {:.1}s", "All passed in {:.1}s", t0.elapsed().as_secs_f64())+ );}}Ok(())diff --git a/apps/iphone-control/src/main.rs b/apps/iphone-control/src/main.rsindex d303b15..0a3e441 100644--- a/apps/iphone-control/src/main.rs+++ b/apps/iphone-control/src/main.rs@@ -16,12 +16,12 @@ use ictl_daemon::protocol::{self, Request, Response};mod debug;#[derive(Parser)]-#[command(name = "iphone-control", version, about = "在 Linux 或 macOS 上控制 iPhone,并提供 MCP 工具")]+#[command(name = "iphone-control", version, about = ictl_l10n::tr!("在 Linux 或 macOS 上控制 iPhone,并提供 MCP 工具", "Control an iPhone from Linux or macOS, with MCP tools"))]struct Cli {- /// 数据根目录(账号、描述文件、日志等)。默认:root 是 /var/lib/iphone-control,普通用户是 ~/.local/share/iphone-control+ #[arg(help = ictl_l10n::tr!("数据根目录(账号、描述文件、日志等)。默认:root 是 /var/lib/iphone-control,普通用户是 ~/.local/share/iphone-control", "Data directory (account, provisioning profiles, logs, ...). Default: /var/lib/iphone-control for root, ~/.local/share/iphone-control for a regular user"))]#[arg(long, env = "ICTL_DATA_DIR", default_value_os_t = protocol::default_data_dir())]data_dir: PathBuf,- /// 守护进程控制接口。默认:root 是 /run/iphone-control/ctl.sock,普通用户是 $XDG_RUNTIME_DIR/iphone-control/ctl.sock+ #[arg(help = ictl_l10n::tr!("守护进程控制接口。默认:root 是 /run/iphone-control/ctl.sock,普通用户是 $XDG_RUNTIME_DIR/iphone-control/ctl.sock", "Daemon control socket. Default: /run/iphone-control/ctl.sock for root, $XDG_RUNTIME_DIR/iphone-control/ctl.sock for a regular user"))]#[arg(long, env = "ICTL_SOCKET", default_value_os_t = protocol::default_socket())]socket: PathBuf,#[command(subcommand)]@@ -30,60 +30,60 @@ struct Cli {#[derive(Subcommand)]enum Command {- /// 常驻守护进程(容器入口;从源码运行时由 systemd 或手动启动)+ #[command(about = ictl_l10n::tr!("常驻守护进程(容器入口;从源码运行时由 systemd 或手动启动)", "The long-running daemon (the container's entry point; for a source install started by systemd or by hand)"))]Daemon,- /// MCP stdio 服务(由 agent 拉起)+ #[command(about = ictl_l10n::tr!("MCP stdio 服务(由 agent 拉起)", "MCP stdio server (started by the agent)"))]Mcp,- /// 打印把 MCP 注册到 Claude Code 的命令:在容器里打印 docker exec 的写法,否则直接调用本程序+ #[command(about = ictl_l10n::tr!("打印把 MCP 注册到 Claude Code 的命令:在容器里打印 docker exec 的写法,否则直接调用本程序", "Print the command that registers the MCP server with Claude Code: a docker exec form inside a container, otherwise this program directly"))]McpConfig {- /// 容器名;给了就按容器部署打印+ #[arg(help = ictl_l10n::tr!("容器名;给了就按容器部署打印", "Container name; if given, print the container form"))]#[arg(long)]container: Option<String>,},- /// 守护进程和设备状态、最近的日志+ #[command(about = ictl_l10n::tr!("守护进程和设备状态、最近的日志", "Daemon and device state, recent log"))]Status,- /// 逐层诊断,每项失败都给出修复办法+ #[command(about = ictl_l10n::tr!("逐层诊断,每项失败都给出修复办法", "Layer-by-layer health check with a fix for each failure"))]Doctor,- /// 首次安装向导:配对 → 开发者模式 → 登录 Apple ID → 签名安装 WDA(可重复运行)+ #[command(about = ictl_l10n::tr!("首次安装向导:配对 → 开发者模式 → 登录 Apple ID → 签名安装 WDA(可重复运行)", "Guided setup: pairing → Developer Mode → Apple ID sign-in → sign and install WDA (safe to re-run)"))]Setup,- /// 登录 Apple ID(密码和双重认证验证码只在这里输入)+ #[command(about = ictl_l10n::tr!("登录 Apple ID(密码和双重认证验证码只在这里输入)", "Sign in to the Apple ID (the password and two-factor code are only entered here)"))]Login {- /// Apple ID 邮箱;不给就交互输入+ #[arg(help = ictl_l10n::tr!("Apple ID 邮箱;不给就交互输入", "Apple ID email; asked for interactively if not given"))]email: Option<String>,},- /// 立即签名并安装 WDA+ #[command(about = ictl_l10n::tr!("立即签名并安装 WDA", "Sign and install WDA now"))]Sign,- /// 检查描述文件,快过期就重签;--force 立即重签+ #[command(about = ictl_l10n::tr!("检查描述文件,快过期就重签;--force 立即重签", "Check the provisioning profile and re-sign if it expires soon; --force re-signs now"))]Resign {#[arg(long)]force: bool,},- /// 设置/删除锁屏密码(自动解锁,默认关闭)+ #[command(about = ictl_l10n::tr!("设置/删除锁屏密码(自动解锁,默认关闭)", "Set or remove the passcode (auto-unlock, off by default)"))]Passcode {#[command(subcommand)]action: PasscodeAction,},- /// 解除自动解锁的停用(输错或中途出错后停用)。只删停用标记,不核对密码:先确认保存的密码对,必要时 passcode set 重设+ #[command(about = ictl_l10n::tr!("解除自动解锁的停用(输错或中途出错后停用)。只删停用标记,不核对密码:先确认保存的密码对,必要时 passcode set 重设", "Re-enable auto-unlock after it was disabled (by a wrong passcode or an error midway). Only removes the flag, doesn't check the passcode: make sure the saved one is right first, or set it again with passcode set"))]UnlockReset,- /// 列出 USB 上接着的设备,标出正在控制哪台+ #[command(about = ictl_l10n::tr!("列出 USB 上接着的设备,标出正在控制哪台", "List devices connected over USB and mark the one being controlled"))]Devices,- /// 改为控制另一台设备,重启后还记得;auto 改回自动选(正在控制的那台断开才换)+ #[command(about = ictl_l10n::tr!("改为控制另一台设备,重启后还记得;auto 改回自动选(正在控制的那台断开才换)", "Control another device, remembered across restarts; auto goes back to automatic (switches only when the controlled one disconnects)"))]Select {- /// UDID、设备名或 auto+ #[arg(help = ictl_l10n::tr!("UDID、设备名或 auto", "UDID, device name or auto"))]device: String,},- /// 显式把 WDA 桥接到 127.0.0.1 供外部工具使用(默认不监听任何端口)+ #[command(about = ictl_l10n::tr!("显式把 WDA 桥接到 127.0.0.1 供外部工具使用(默认不监听任何端口)", "Explicitly expose WDA on 127.0.0.1 for other tools (by default no port is opened)"))]WdaBridge {#[arg(long, default_value_t = 8100)]port: u16,},- /// 真机诊断(开发用,要用 `--features debug-cmds` 编译)。`wda`/`e2e`/`hid` 会和守护进程抢 XCTest、HID,先停掉守护进程+ #[command(about = ictl_l10n::tr!("真机诊断(开发用,要用 `--features debug-cmds` 编译)。`wda`/`e2e`/`hid` 会和守护进程抢 XCTest、HID,先停掉守护进程", "Real-device diagnostics (for development, build with `--features debug-cmds`). `wda`/`e2e`/`hid` compete with the daemon for XCTest and HID, so stop the daemon first"))]#[cfg(feature = "debug-cmds")]#[command(hide = true)]Debug(debug::DebugArgs),- /// 按已配置的渠道发测试通知:每类事件各一条(标题带「[测试]」),或只发指定的一类+ #[command(about = ictl_l10n::tr!("按已配置的渠道发测试通知:每类事件各一条(标题带「[测试]」),或只发指定的一类", "Send test notifications over the configured channels: one per event type (title starts with “[test]”), or only the given one"))]NotifyTest {- /// resign / session / pin / pin-recovered / unlock / offline / online;不给就全发+ #[arg(help = ictl_l10n::tr!("resign / session / pin / pin-recovered / unlock / offline / online;不给就全发", "resign / session / pin / pin-recovered / unlock / offline / online; all if not given"))]event: Option<String>,},}@@ -92,15 +92,15 @@ enum Command {#[derive(Subcommand)]enum PasscodeAction {Set {- /// 哪台设备(UDID 或设备名);不给就是守护进程正在控制的那台+ #[arg(help = ictl_l10n::tr!("哪台设备(UDID 或设备名);不给就是守护进程正在控制的那台", "Which device (UDID or name); defaults to the one the daemon controls"))]#[arg(long)]device: Option<String>,},Clear {- /// 哪台设备(UDID 或设备名);不给就是守护进程正在控制的那台+ #[arg(help = ictl_l10n::tr!("哪台设备(UDID 或设备名);不给就是守护进程正在控制的那台", "Which device (UDID or name); defaults to the one the daemon controls"))]#[arg(long)]device: Option<String>,- /// 删掉所有设备的密码+ #[arg(help = ictl_l10n::tr!("删掉所有设备的密码", "Delete the passcodes of all devices"))]#[arg(long, conflicts_with = "device")]all: bool,},@@ -158,31 +158,45 @@ async fn notify_test(data_dir: &Path, only: Option<&str>) -> anyhow::Result<()>usize::from(cfg.bark_key.is_some()) + usize::from(cfg.tg_bot_token.is_some() && cfg.tg_chat_id.is_some());if channels == 0 {bail!(- "没有配置通知渠道:填 BARK_KEY,或 TG_BOT_TOKEN + TG_CHAT_ID(容器部署在 .env 里填、重建容器;\- 从源码运行在守护进程的环境文件里填、重启守护进程)"+ "{}",+ ictl_l10n::tr!(+ "没有配置通知渠道:填 BARK_KEY,或 TG_BOT_TOKEN + TG_CHAT_ID(容器部署在 .env 里填、重建容器;\+ 从源码运行在守护进程的环境文件里填、重启守护进程)",+ "No notification channel configured: set BARK_KEY, or TG_BOT_TOKEN + TG_CHAT_ID (container: in .env, then recreate the container; source install: in the daemon's env file, then restart the daemon)"+ ));}let events: Vec<Event> =Event::samples().into_iter().filter(|e| only.is_none_or(|n| e.sample_name() == n)).collect();if events.is_empty() {let names: Vec<&str> = Event::samples().iter().map(|e| e.sample_name()).collect();- bail!("没有这类事件,可选:{}", names.join(" / "));+ bail!("{}", ictl_l10n::trf!("没有这类事件,可选:{}", "No such event; choose from: {}", names.join(" / ")));}let mut failed = 0;for e in &events {let (title, body) = e.title_body();- let ok = send(&cfg, &format!("[测试] {title}"), &body).await;+ let ok = send(&cfg, &ictl_l10n::trf!("[测试] {title}", "[test] {title}"), &body).await;println!(- "{} {:<14} {title}({ok}/{channels} 个渠道成功)",- if ok == channels { "✅" } else { "❌" },- e.sample_name()+ "{}",+ ictl_l10n::trf!(+ "{} {:<14} {title}({ok}/{channels} 个渠道成功)",+ "{} {:<14} {title} ({ok}/{channels} channels succeeded)",+ if ok == channels { "✅" } else { "❌" },+ e.sample_name()+ ));failed += usize::from(ok < channels);// Bark 同组消息太密会被手机合并,隔一下tokio::time::sleep(std::time::Duration::from_millis(500)).await;}if failed > 0 {- bail!("{failed} 条没有全部发出去,详见上面的 WARN 日志");+ bail!(+ "{}",+ ictl_l10n::trf!(+ "{failed} 条没有全部发出去,详见上面的 WARN 日志",+ "{failed} notification(s) were not sent to every channel, see the WARN log above"+ )+ );}Ok(())}@@ -196,9 +210,12 @@ fn mcp_config(container: Option<String>, socket: &Path) -> anyhow::Result<StringOk(match container {Some(c) => format!("claude mcp add iphone -s user -- docker exec -i {c} iphone-control mcp"),None => {- let exe = std::env::current_exe().context("找不到本程序的路径")?;+ let exe = std::env::current_exe()+ .context(ictl_l10n::tr!("找不到本程序的路径", "can't find the path of this program"))?;+ // 容器里的 MCP 进程继承容器的 .env;直接调用时语言要写进 MCP 配置+ let lang = if ictl_l10n::is_en() { format!("-e {}=en ", ictl_l10n::ENV) } else { String::new() };format!(- "claude mcp add iphone -s user -- {} --socket {} mcp",+ "claude mcp add iphone -s user {lang}-- {} --socket {} mcp",shell_quote(&exe.to_string_lossy()),shell_quote(&socket.to_string_lossy()))@@ -221,9 +238,8 @@ async fn ask(socket: &Path, req: Request) -> anyhow::Result<Response> {_ => Some(Duration::from_secs(180)),};protocol::call(socket, &req, timeout).await.with_context(|| {- format!(- "连不上守护进程({}):先启动 iphone-control daemon(容器里是入口进程);\- 守护进程以别的用户运行时,用 --socket 或 ICTL_SOCKET 指到它的控制接口",+ ictl_l10n::trf!("连不上守护进程({}):先启动 iphone-control daemon(容器里是入口进程);\+ 守护进程以别的用户运行时,用 --socket 或 ICTL_SOCKET 指到它的控制接口", "Can't reach the daemon ({}): start iphone-control daemon first (in the container it is the entry process); if the daemon runs as another user, point --socket or ICTL_SOCKET at its control socket",socket.display())})@@ -247,56 +263,116 @@ async fn snapshot(socket: &Path) -> anyhow::Result<ictl_daemon::Snapshot> {match ask(socket, Request::Daemon).await? {Response::Text { text, .. } => Ok(serde_json::from_str(&text)?),Response::Error { message } => bail!("{message}"),- Response::Image { .. } => bail!("守护进程返回了意外的响应"),+ Response::Image { .. } => {+ bail!("{}", ictl_l10n::tr!("守护进程返回了意外的响应", "The daemon sent an unexpected response"))+ }}}async fn status(socket: &Path) -> anyhow::Result<()> {let s = snapshot(socket).await?;- println!("状态 {}", s.state.describe());+ println!("{}", ictl_l10n::trf!("状态 {}", "State {}", s.state.describe()));if let Some(d) = &s.device {- println!("手机 {} {} iOS {}", d.udid, d.product_type, d.product_version);+ println!(+ "{}",+ ictl_l10n::trf!(+ "手机 {} {} iOS {}",+ "Phone {} {} iOS {}",+ d.udid,+ d.product_type,+ d.product_version+ )+ );}let current = s.device.as_ref().map(|d| d.udid.as_str());let others: Vec<String> =s.devices.iter().filter(|d| Some(d.udid.as_str()) != current).map(ictl_daemon::core::device_label).collect();if !others.is_empty() {- println!("另外接着 {}(iphone-control select 切换)", others.join("、"));+ println!(+ "{}",+ ictl_l10n::trf!(+ "另外接着 {}(iphone-control select 切换)",+ "Also on {} (switch with iphone-control select)",+ others.join(ictl_l10n::tr!("、", ", "))+ )+ );}match (&s.pinned, s.pinned_by_env) {- (Some(p), true) => println!("选设备 IPHONE_UDID 固定为 {p}"),- (Some(p), false) => println!("选设备 选定了 {p}(iphone-control select auto 改回自动选)"),- (None, _) if !others.is_empty() => println!("选设备 自动(正在控制的那台断开才换)"),+ (Some(p), true) => println!(+ "{}",+ ictl_l10n::trf!("选设备 IPHONE_UDID 固定为 {p}", "Device pinned by IPHONE_UDID to {p}")+ ),+ (Some(p), false) => println!(+ "{}",+ ictl_l10n::trf!(+ "选设备 选定了 {p}(iphone-control select auto 改回自动选)",+ "Device {p} selected (iphone-control select auto for automatic)"+ )+ ),+ (None, _) if !others.is_empty() => println!(+ "{}",+ ictl_l10n::tr!(+ "选设备 自动(正在控制的那台断开才换)",+ "Device automatic (switches only when the controlled one disconnects)"+ )+ ),(None, _) => {}}let p = &s.persisted;- println!("WDA {}", p.wda_bundle.as_deref().unwrap_or("未签名"));+ println!("WDA {}", p.wda_bundle.as_deref().unwrap_or(ictl_l10n::tr!("未签名", "not signed")));match &s.device_profile {ictl_daemon::core::DeviceProfile::Missing => {- println!("描述文件 这台手机上没有装当前 Apple ID 签的 WDA(iphone-control setup)")+ println!(+ "{}",+ ictl_l10n::tr!(+ "描述文件 这台手机上没有装当前 Apple ID 签的 WDA(iphone-control setup)",+ "Profile no WDA signed by the current Apple ID on this phone (iphone-control setup)"+ )+ )}dp => {if let Some(left) = dp.left(p) {let whose = if matches!(dp, ictl_daemon::core::DeviceProfile::Expires(_)) {- "手机上的"+ ictl_l10n::tr!("手机上的", "on the phone, ")} else {- "上次签的"+ ictl_l10n::tr!("上次签的", "last signed, ")};- println!("描述文件 {whose}还剩 {} 小时", left.as_secs() / 3600);+ println!(+ "{}",+ ictl_l10n::trf!(+ "描述文件 {whose}还剩 {} 小时",+ "Profile {whose}{} hours left",+ left.as_secs() / 3600+ )+ );}}}if let Some(r) = &p.last_resign {- println!("上次重签 {r}");+ println!("{}", ictl_l10n::trf!("上次重签 {r}", "Re-signed {r}"));}let unlock = match (s.auto_unlock, s.unlock_disabled) {- (_, true) => "已停用(之前输错过,iphone-control unlock-reset)",- (true, false) => "已启用",- (false, false) => "未启用",+ (_, true) => ictl_l10n::tr!(+ "已停用(之前输错过,iphone-control unlock-reset)",+ "disabled (a wrong passcode earlier; iphone-control unlock-reset)"+ ),+ (true, false) => ictl_l10n::tr!("已启用", "enabled"),+ (false, false) => ictl_l10n::tr!("未启用", "off"),};- println!("自动解锁 {unlock}");- println!("通知 {}", if s.notify_configured { "已配置" } else { "未配置" });- println!("\n最近日志:");+ println!("{}", ictl_l10n::trf!("自动解锁 {unlock}", "Unlock {unlock}"));+ println!(+ "{}",+ ictl_l10n::trf!(+ "通知 {}",+ "Notify {}",+ if s.notify_configured {+ ictl_l10n::tr!("已配置", "configured")+ } else {+ ictl_l10n::tr!("未配置", "not configured")+ }+ )+ );+ println!("{}", ictl_l10n::tr!("\n最近日志:", "\nRecent log:"));for l in s.log_tail {println!(" {l}");}@@ -308,7 +384,13 @@ fn read_line(prompt: &str) -> anyhow::Result<String> {std::io::stdout().flush()?;let mut s = String::new();if std::io::stdin().lock().read_line(&mut s)? == 0 {- bail!("读不到输入(标准输入已关闭):在终端里运行;容器部署用 docker exec -it");+ bail!(+ "{}",+ ictl_l10n::tr!(+ "读不到输入(标准输入已关闭):在终端里运行;容器部署用 docker exec -it",+ "Can't read input (stdin is closed): run it in a terminal; for a container use docker exec -it"+ )+ );}Ok(s.trim().to_owned())}@@ -339,27 +421,40 @@ fn account_dir(data_dir: &Path) -> ictl_sign::AccountDir {}async fn login(data_dir: &Path, email: Option<String>) -> anyhow::Result<()> {- println!("建议用一个专门的免费 Apple ID,不要用主账号。");println!(- "密码和验证码由本程序直接发给苹果;登录时会请求 anisette 服务生成设备标识(默认第三方,可用 ICTL_ANISETTE_URL 改成自建)。"+ "{}",+ ictl_l10n::tr!(+ "建议用一个专门的免费 Apple ID,不要用主账号。",+ "Use a dedicated free Apple ID, not your main account."+ )+ );+ println!(+ "{}",+ ictl_l10n::tr!(+ "密码和验证码由本程序直接发给苹果;登录时会请求 anisette 服务生成设备标识(默认第三方,可用 ICTL_ANISETTE_URL 改成自建)。",+ "The password and verification code go straight from this program to Apple; signing in asks an anisette service for device identifiers (a third-party one by default, set ICTL_ANISETTE_URL to use your own)."+ ));let email = match email {Some(e) => e,- None => read_line("Apple ID 邮箱: ")?,+ None => read_line(ictl_l10n::tr!("Apple ID 邮箱: ", "Apple ID email: "))?,};if email.is_empty() {- bail!("没有输入 Apple ID 邮箱");+ bail!("{}", ictl_l10n::tr!("没有输入 Apple ID 邮箱", "No Apple ID email entered"));}- let password = read_secret("密码(输入不显示): ")?;+ let password = read_secret(ictl_l10n::tr!("密码(输入不显示): ", "Password (hidden): "))?;if password.is_empty() {- bail!("没有输入密码");+ bail!("{}", ictl_l10n::tr!("没有输入密码", "No password entered"));}let two_factor = |req: ictl_sign::TwoFactorRequest| -> Result<ictl_sign::TwoFactorAction, String> {let sms = !req.trusted_phone_numbers.is_empty();let prompt = match req.method {- ictl_sign::TwoFactorMethod::Sms => "短信验证码: ",- ictl_sign::TwoFactorMethod::Device if sms => "设备上收到的验证码(输入 sms 改为短信接收): ",- ictl_sign::TwoFactorMethod::Device => "设备上收到的验证码: ",+ ictl_sign::TwoFactorMethod::Sms => ictl_l10n::tr!("短信验证码: ", "SMS code: "),+ ictl_sign::TwoFactorMethod::Device if sms => ictl_l10n::tr!(+ "设备上收到的验证码(输入 sms 改为短信接收): ",+ "Code shown on your device (enter sms to get it by text message): "+ ),+ ictl_sign::TwoFactorMethod::Device => ictl_l10n::tr!("设备上收到的验证码: ", "Code shown on your device: "),};let code = read_line(prompt).map_err(|e| e.to_string())?;if sms && code.eq_ignore_ascii_case("sms") {@@ -368,7 +463,14 @@ async fn login(data_dir: &Path, email: Option<String>) -> anyhow::Result<()> {Ok(ictl_sign::TwoFactorAction::SubmitCode(code))};account_dir(data_dir).login(&email, &password, two_factor).await?;- println!("登录成功,会话已保存到 {}", account_dir(data_dir).dir.display());+ println!(+ "{}",+ ictl_l10n::trf!(+ "登录成功,会话已保存到 {}",+ "Signed in, session saved to {}",+ account_dir(data_dir).dir.display()+ )+ );Ok(())}@@ -407,8 +509,21 @@ async fn target_device(socket: &Path, query: Option<&str>) -> anyhow::Result<ict}match &infos[..] {[one] => Ok(one.clone()),- [] => bail!("没接设备:用数据线接好并解锁"),- _ => bail!("接着 {} 台设备,不知道是哪台:先用 iphone-control select 选一台,或加 --device 指定", infos.len()),+ [] => bail!(+ "{}",+ ictl_l10n::tr!(+ "没接设备:用数据线接好并解锁",+ "No device connected: plug it in with a data cable and unlock it"+ )+ ),+ _ => bail!(+ "{}",+ ictl_l10n::trf!(+ "接着 {} 台设备,不知道是哪台:先用 iphone-control select 选一台,或加 --device 指定",+ "{} devices connected, not sure which one: choose one with iphone-control select, or pass --device",+ infos.len()+ )+ ),}}@@ -419,30 +534,73 @@ async fn passcode(data_dir: &Path, socket: &Path, action: PasscodeAction) -> anyPasscodeAction::Clear { all: true, .. } => {let _ = std::fs::remove_dir_all(cfg.passcodes_dir());let _ = std::fs::remove_file(cfg.legacy_passcode_file());- println!("已删除所有设备的锁屏密码,自动解锁关闭。");+ println!(+ "{}",+ ictl_l10n::tr!(+ "已删除所有设备的锁屏密码,自动解锁关闭。",+ "Deleted the passcodes of all devices, auto-unlock is off."+ )+ );}PasscodeAction::Clear { device, .. } => {let d = target_device(socket, device.as_deref()).await?;let _ = std::fs::remove_file(cfg.passcode_file_for(&d.udid));- println!("已删除 {} 的锁屏密码,这台的自动解锁关闭。", ictl_daemon::core::device_label(&d));+ println!(+ "{}",+ ictl_l10n::trf!(+ "已删除 {} 的锁屏密码,这台的自动解锁关闭。",+ "Deleted the passcode of {}, auto-unlock is off for it.",+ ictl_daemon::core::device_label(&d)+ )+ );}PasscodeAction::Set { device } => {let d = target_device(socket, device.as_deref()).await?;let path = cfg.passcode_file_for(&d.udid);- println!("设备:{}", ictl_daemon::core::device_label(&d));- println!("自动解锁:锁屏后,MCP 操作前会用这个密码解锁手机。");- println!("风险:能登录这台机器、或能调用这个 MCP 的人,都能解锁你的手机。");- println!("保护:每按一位都核对;整串输完仍锁着就停用自动解锁并推送通知,不会累计输错。只支持纯数字。");- let p = read_secret("锁屏密码(输入不显示): ")?;+ println!("{}", ictl_l10n::trf!("设备:{}", "Device: {}", ictl_daemon::core::device_label(&d)));+ println!(+ "{}",+ ictl_l10n::tr!(+ "自动解锁:锁屏后,MCP 操作前会用这个密码解锁手机。",+ "Auto-unlock: when the phone is locked, MCP actions use this passcode to unlock it first."+ )+ );+ println!(+ "{}",+ ictl_l10n::tr!(+ "风险:能登录这台机器、或能调用这个 MCP 的人,都能解锁你的手机。",+ "Risk: anyone who can log in to this machine or call this MCP server can unlock your phone."+ )+ );+ println!(+ "{}",+ ictl_l10n::tr!(+ "保护:每按一位都核对;整串输完仍锁着就停用自动解锁并推送通知,不会累计输错。只支持纯数字。",+ "Safeguards: every digit is checked; if the phone is still locked after the whole passcode, auto-unlock is disabled and a notification is sent, so wrong attempts don't pile up. Numeric passcodes only."+ )+ );+ let p = read_secret(ictl_l10n::tr!("锁屏密码(输入不显示): ", "Passcode (hidden): "))?;if p.len() < 4 || !p.bytes().all(|b| b.is_ascii_digit()) {- bail!("只支持 4 位以上的纯数字密码");+ bail!(+ "{}",+ ictl_l10n::tr!(+ "只支持 4 位以上的纯数字密码",+ "Only numeric passcodes with 4 or more digits are supported"+ )+ );}cfg.ensure_passcodes_dir()?;let mut f = std::fs::OpenOptions::new().create(true).write(true).truncate(true).mode(0o600).open(&path)?;// mode() 只在新建时生效:已有文件也收紧f.set_permissions(std::fs::Permissions::from_mode(0o600))?;f.write_all(p.as_bytes())?;- println!("已保存(只用于这台设备)。别忘了在手机上把「自动锁定」从「永不」改回较短时间。");+ println!(+ "{}",+ ictl_l10n::tr!(+ "已保存(只用于这台设备)。别忘了在手机上把「自动锁定」从「永不」改回较短时间。",+ "Saved (for this device only). Remember to set Auto-Lock on the phone back from “Never” to a shorter time."+ )+ );}}Ok(())@@ -469,27 +627,41 @@ whereasync fn setup(cli: &Cli) -> anyhow::Result<()> {use ictl_device::{Device, DeviceError};let socket = &cli.socket;- snapshot(socket).await.context("setup 需要守护进程在运行")?;+ snapshot(socket)+ .await+ .context(ictl_l10n::tr!("setup 需要守护进程在运行", "setup needs the daemon to be running"))?;- println!("[1/6] 等待手机连接");+ println!("{}", ictl_l10n::tr!("[1/6] 等待手机连接", "[1/6] Waiting for the phone"));let found = wait_until(Duration::from_secs(600), Duration::from_secs(5), || async {ictl_device::list_devices().await.map(|d| !d.is_empty()).unwrap_or(false)}).await;if !found {- bail!("10 分钟内没检测到手机:用数据线接好并解锁手机");+ bail!(+ "{}",+ ictl_l10n::tr!(+ "10 分钟内没检测到手机:用数据线接好并解锁手机",+ "No phone detected within 10 minutes: plug it in with a data cable and unlock it"+ )+ );}// 和守护进程控制同一台:第 5 步的签名安装是守护进程对它正在控制的那台做的let target = target_device(socket, None).await?;let udid = Some(target.udid.clone());let device = Device::find(udid.as_deref()).await?;- println!(" 手机 {}", ictl_daemon::core::device_label(&target));+ println!("{}", ictl_l10n::trf!(" 手机 {}", " Phone {}", ictl_daemon::core::device_label(&target)));- println!("[2/6] 配对");+ println!("{}", ictl_l10n::tr!("[2/6] 配对", "[2/6] Pairing"));if device.paired().await? {- println!(" 已配对");+ println!("{}", ictl_l10n::tr!(" 已配对", " Already paired"));} else {- println!(" 手机上会弹出「要信任此电脑吗?」:点「信任」,再输入锁屏密码。");+ println!(+ "{}",+ ictl_l10n::tr!(+ " 手机上会弹出「要信任此电脑吗?」:点「信任」,再输入锁屏密码。",+ " The phone shows “Trust This Computer?”: tap “Trust” and enter the passcode."+ )+ );let ok = wait_until(Duration::from_secs(300), Duration::from_secs(5), || async {match device.pair("iphone-control").await {Ok(()) => true,@@ -502,18 +674,30 @@ async fn setup(cli: &Cli) -> anyhow::Result<()> {}).await;if !ok {- bail!("5 分钟内没完成配对");+ bail!("{}", ictl_l10n::tr!("5 分钟内没完成配对", "Pairing not completed within 5 minutes"));}- println!(" 配对成功");+ println!("{}", ictl_l10n::tr!(" 配对成功", " Paired"));}- println!("[3/6] 开发者模式");+ println!("{}", ictl_l10n::tr!("[3/6] 开发者模式", "[3/6] Developer Mode"));if device.developer_mode_enabled().await.unwrap_or(false) {- println!(" 已打开");+ println!("{}", ictl_l10n::tr!(" 已打开", " Already on"));} else {let _ = device.reveal_developer_mode().await;- println!(" 请在手机上:设置 → 隐私与安全性 → 开发者模式 → 打开 → 重新启动;");- println!(" 重启后解锁,在弹窗里点「打开」并输入密码。手机重启期间连接会断开,会自动恢复。");+ println!(+ "{}",+ ictl_l10n::tr!(+ " 请在手机上:设置 → 隐私与安全性 → 开发者模式 → 打开 → 重新启动;",+ " On the phone: Settings → Privacy & Security → Developer Mode → on → Restart;"+ )+ );+ println!(+ "{}",+ ictl_l10n::tr!(+ " 重启后解锁,在弹窗里点「打开」并输入密码。手机重启期间连接会断开,会自动恢复。",+ " after the restart, unlock it, tap “Turn On” in the prompt and enter the passcode. The connection drops while the phone restarts and recovers by itself."+ )+ );let ok = wait_until(Duration::from_secs(900), Duration::from_secs(10), || async {match Device::find(udid.as_deref()).await {Ok(d) => d.developer_mode_enabled().await.unwrap_or(false),@@ -522,18 +706,27 @@ async fn setup(cli: &Cli) -> anyhow::Result<()> {}).await;if !ok {- bail!("15 分钟内没检测到开发者模式打开");+ bail!(+ "{}",+ ictl_l10n::tr!("15 分钟内没检测到开发者模式打开", "Developer Mode not turned on within 15 minutes")+ );}- println!(" 已打开");+ println!("{}", ictl_l10n::tr!(" 已打开", " Turned on"));}- println!("[4/6] 登录 Apple ID");+ println!("{}", ictl_l10n::tr!("[4/6] 登录 Apple ID", "[4/6] Apple ID sign-in"));match account_dir(&cli.data_dir).selected_email().await {- Ok(e) => println!(" 已登录 {e}"),+ Ok(e) => println!("{}", ictl_l10n::trf!(" 已登录 {e}", " Signed in as {e}")),Err(_) => login(&cli.data_dir, None).await?,}- println!("[5/6] 注册设备、签名 WDA 并安装到手机(手机要保持解锁)");+ println!(+ "{}",+ ictl_l10n::tr!(+ "[5/6] 注册设备、签名 WDA 并安装到手机(手机要保持解锁)",+ "[5/6] Registering the device, signing WDA and installing it on the phone (keep the phone unlocked)"+ )+ );// 前几步直接问 usbmuxd,重签却由守护进程做:它每 10 秒巡检一次才认到手机。手机刚重启完、usbmuxd 刚重启时// 这里会先看到手机,马上请求重签就报「手机未连接」,所以先等守护进程认到同一台let target = device.udid.clone();@@ -544,23 +737,67 @@ async fn setup(cli: &Cli) -> anyhow::Result<()> {}).await;if !seen {- bail!("守护进程 1 分钟内没认到手机 {},运行 iphone-control doctor 看看卡在哪", device.udid);+ bail!(+ "{}",+ ictl_l10n::trf!(+ "守护进程 1 分钟内没认到手机 {},运行 iphone-control doctor 看看卡在哪",+ "The daemon didn't pick up the phone {} within a minute; run iphone-control doctor to see where it is stuck",+ device.udid+ )+ );}print_text(socket, Request::Resign { force: true }).await?;- println!("[6/6] 等待 WDA 启动");- println!(" 首次安装:在手机 设置 → 通用 → VPN 与设备管理 里找到你的 Apple ID,点「信任」(需要联网)。");- println!(" 如果弹出「为 XCTest 输入 iPhone 密码」,输入锁屏密码。");+ println!("{}", ictl_l10n::tr!("[6/6] 等待 WDA 启动", "[6/6] Waiting for WDA to start"));+ println!(+ "{}",+ ictl_l10n::tr!(+ " 首次安装:在手机 设置 → 通用 → VPN 与设备管理 里找到你的 Apple ID,点「信任」(需要联网)。",+ " First install: on the phone, open Settings → General → VPN & Device Management, find your Apple ID and tap “Trust” (needs internet)."+ )+ );+ println!(+ "{}",+ ictl_l10n::tr!(+ " 如果弹出「为 XCTest 输入 iPhone 密码」,输入锁屏密码。",+ " If “Enter iPhone passcode for XCTest” appears, enter the passcode."+ )+ );let ready = wait_until(Duration::from_secs(600), Duration::from_secs(10), || async {snapshot(socket).await.map(|s| s.state == ictl_daemon::machine::DeviceState::Ready).unwrap_or(false)}).await;- println!(" {}", if ready { "WDA 就绪" } else { "10 分钟内 WDA 没就绪,运行 iphone-control doctor 看看卡在哪" });+ println!(+ " {}",+ if ready {+ ictl_l10n::tr!("WDA 就绪", "WDA ready")+ } else {+ ictl_l10n::tr!(+ "10 分钟内 WDA 没就绪,运行 iphone-control doctor 看看卡在哪",+ "WDA wasn't ready within 10 minutes; run iphone-control doctor to see where it is stuck"+ )+ }+ );- println!("\n可选设置");- println!(" 通知:填 TG_* 或 BARK_*(容器部署在 .env 里,然后重建容器;从源码运行在守护进程的环境文件里,然后重启它)");- println!(" 自动解锁:iphone-control passcode set");- println!(" 注册到 Claude Code:iphone-control mcp-config");+ println!("{}", ictl_l10n::tr!("\n可选设置", "\nOptional"));+ println!(+ "{}",+ ictl_l10n::tr!(+ " 通知:填 TG_* 或 BARK_*(容器部署在 .env 里,然后重建容器;从源码运行在守护进程的环境文件里,然后重启它)",+ " Notifications: set TG_* or BARK_* (container: in .env, then recreate the container; source install: in the daemon's env file, then restart it)"+ )+ );+ println!(+ "{}",+ ictl_l10n::tr!(" 自动解锁:iphone-control passcode set", " Auto-unlock: iphone-control passcode set")+ );+ println!(+ "{}",+ ictl_l10n::tr!(+ " 注册到 Claude Code:iphone-control mcp-config",+ " Register with Claude Code: iphone-control mcp-config"+ )+ );println!();print_text(socket, Request::Doctor).await}@@ -573,8 +810,21 @@ async fn wda_bridge(socket: &Path, port: u16) -> anyhow::Result<()> {let target = target_device(socket, None).await?;let device = ictl_device::Device::find(Some(&target.udid)).await?;let listener = tokio::net::TcpListener::bind(("127.0.0.1", port)).await?;- println!("WDA 桥接 127.0.0.1:{port} → 手机 {} 的 8100 端口(Ctrl-C 停止)", device.udid);- println!("注意:本机所有用户都能经这个端口控制手机(WDA 没有认证),用完就停掉。");+ println!(+ "{}",+ ictl_l10n::trf!(+ "WDA 桥接 127.0.0.1:{port} → 手机 {} 的 8100 端口(Ctrl-C 停止)",+ "WDA bridge 127.0.0.1:{port} → port 8100 on phone {} (Ctrl-C to stop)",+ device.udid+ )+ );+ println!(+ "{}",+ ictl_l10n::tr!(+ "注意:本机所有用户都能经这个端口控制手机(WDA 没有认证),用完就停掉。",+ "Note: every user on this machine can control the phone through this port (WDA has no authentication); stop it when you're done."+ )+ );loop {let (client, _) = listener.accept().await?;let device = device.clone();@@ -594,7 +844,7 @@ async fn bridge_conn(mut client: tokio::net::TcpStream, device: &ictl_device::Delet mut buf = [0u8; 4096];while !head.windows(4).any(|w| w == b"\r\n\r\n") {if head.len() > 64 * 1024 {- bail!("请求头太长");+ bail!("{}", ictl_l10n::tr!("请求头太长", "request headers too long"));}let n = client.read(&mut buf).await?;if n == 0 {diff --git a/crates/ictl-daemon/src/doctor.rs b/crates/ictl-daemon/src/doctor.rsindex c1d130b..79900f7 100644--- a/crates/ictl-daemon/src/doctor.rs+++ b/crates/ictl-daemon/src/doctor.rs@@ -9,18 +9,17 @@ impl Daemon {let mut out: Vec<String> = Vec::new();let mut fails = 0;- out.push("== 设备连接".into());+ out.push(ictl_l10n::tr!("== 设备连接", "== Device connection").into());match ictl_device::list_devices().await {- Ok(_) => out.push("✅ usbmuxd 在运行".into()),+ Ok(_) => out.push(ictl_l10n::tr!("✅ usbmuxd 在运行", "✅ usbmuxd is running").into()),Err(e) => {- out.push(format!(- "❌ 连不上 usbmuxd:{e}\n → {}",+ out.push(ictl_l10n::trf!("❌ 连不上 usbmuxd:{e}\n → {}", "❌ Can't reach usbmuxd: {e}\n → {}",if self.cfg.manage_usbmuxd {- "由守护进程自动拉起,看数据目录 logs/usbmuxd.log;宿主机已有 usbmuxd 服务时设 ICTL_MANAGE_USBMUXD=0"+ ictl_l10n::tr!("由守护进程自动拉起,看数据目录 logs/usbmuxd.log;宿主机已有 usbmuxd 服务时设 ICTL_MANAGE_USBMUXD=0", "the daemon starts it itself, see logs/usbmuxd.log in the data directory; if the host already runs a usbmuxd service, set ICTL_MANAGE_USBMUXD=0")} else if cfg!(target_os = "macos") {- "macOS 自带 usbmuxd,应一直在运行:sudo launchctl kickstart -k system/com.apple.usbmuxd"+ ictl_l10n::tr!("macOS 自带 usbmuxd,应一直在运行:sudo launchctl kickstart -k system/com.apple.usbmuxd", "macOS ships usbmuxd and it should always be running: sudo launchctl kickstart -k system/com.apple.usbmuxd")} else {- "用的是系统的 usbmuxd 服务(插上手机时由 udev 拉起):确认已安装 usbmuxd、手机已插好"+ ictl_l10n::tr!("用的是系统的 usbmuxd 服务(插上手机时由 udev 拉起):确认已安装 usbmuxd、手机已插好", "using the system usbmuxd service (udev starts it when the phone is plugged in): make sure usbmuxd is installed and the phone is plugged in")}));fails += 1;@@ -28,9 +27,9 @@ impl Daemon {}// 判断不了(不是 Linux/macOS)就不报,免得误报「没有设备」match ictl_device::host_ios_usb_present().await {- Some(true) => out.push("✅ USB 上有 iPhone/iPad".into()),+ Some(true) => out.push(ictl_l10n::tr!("✅ USB 上有 iPhone/iPad", "✅ An iPhone/iPad is on USB").into()),Some(false) => {- out.push("❌ USB 上没有 iPhone/iPad\n → 插好数据线;用 USB-C 转接头的话换一根试试".into());+ out.push(ictl_l10n::tr!("❌ USB 上没有 iPhone/iPad\n → 插好数据线;用 USB-C 转接头的话换一根试试", "❌ No iPhone/iPad on USB\n → check the data cable; if you use a USB-C adapter, try another cable").into());fails += 1;}None => {}@@ -38,134 +37,200 @@ impl Daemon {match (&g.device, &g.info) {(Some(d), info) => {let i = info.clone().unwrap_or_default();- out.push(format!("✅ 已连接 {} {} iOS {}", d.udid, i.product_type, i.product_version));+ out.push(ictl_l10n::trf!(+ "✅ 已连接 {} {} iOS {}",+ "✅ Connected {} {} iOS {}",+ d.udid,+ i.product_type,+ i.product_version+ ));let major = i.major_version();if major > 0 && major < 17 {- out.push("⚠️ iOS 低于 17 未在此版本测试过".into());+ out.push(+ ictl_l10n::tr!(+ "⚠️ iOS 低于 17 未在此版本测试过",+ "⚠️ iOS below 17 not tested on this version"+ )+ .into(),+ );} else if major > 0 && major < 27 {- out.push("⚠️ iOS 低于 27 HID 后备路线(免签名截图/点击)不可用,只能走 WDA".into());+ out.push(+ ictl_l10n::tr!(+ "⚠️ iOS 低于 27 HID 后备路线(免签名截图/点击)不可用,只能走 WDA",+ "⚠️ iOS below 27 no HID fallback (screenshots/taps without signing), WDA only"+ )+ .into(),+ );}}// 选定的那台没接、别的接着:usbmuxd 没问题,不是重启它能解决的(None, _) if self.pinned(g).is_some() && !g.connected.is_empty() => {let p = self.pinned(g).unwrap_or_default();let how = if self.cfg.udid.is_some() {- "或改 .env 里的 IPHONE_UDID"+ ictl_l10n::tr!("或改 .env 里的 IPHONE_UDID", "or change IPHONE_UDID in .env")} else {- "或 iphone-control select 换成接着的另一台(auto 改回自动选)"+ ictl_l10n::tr!(+ "或 iphone-control select 换成接着的另一台(auto 改回自动选)",+ "or switch to another connected device with iphone-control select (auto for automatic)"+ )};- out.push(format!("❌ 选定的设备 {p} 没连接\n → 接上它;{how}"));+ out.push(ictl_l10n::trf!(+ "❌ 选定的设备 {p} 没连接\n → 接上它;{how}",+ "❌ The selected device {p} is not connected\n → plug it in; {how}"+ ));fails += 1;}(None, _) => {out.push(if self.cfg.manage_usbmuxd {- "❌ 守护进程看不到手机\n → 等 30 秒,会自动重启 usbmuxd;仍不行就重启容器(或守护进程)"+ ictl_l10n::tr!("❌ 守护进程看不到手机\n → 等 30 秒,会自动重启 usbmuxd;仍不行就重启容器(或守护进程)", "❌ The daemon can't see the phone\n → wait 30 seconds, usbmuxd restarts automatically; if that doesn't help, restart the container (or the daemon)")} else if cfg!(target_os = "macos") {- "❌ 守护进程看不到手机\n → 重新插拔数据线;仍不行就 sudo launchctl kickstart -k system/com.apple.usbmuxd"+ ictl_l10n::tr!("❌ 守护进程看不到手机\n → 重新插拔数据线;仍不行就 sudo launchctl kickstart -k system/com.apple.usbmuxd", "❌ The daemon can't see the phone\n → replug the cable; if that doesn't help, sudo launchctl kickstart -k system/com.apple.usbmuxd")} else {- "❌ 守护进程看不到手机\n → 重新插拔数据线;仍不行就 sudo systemctl restart usbmuxd"+ ictl_l10n::tr!("❌ 守护进程看不到手机\n → 重新插拔数据线;仍不行就 sudo systemctl restart usbmuxd", "❌ The daemon can't see the phone\n → replug the cable; if that doesn't help, sudo systemctl restart usbmuxd")}.into(),);fails += 1;}}- out.push(format!(" 状态:{}", g.state.describe()));+ out.push(ictl_l10n::trf!(" 状态:{}", " State: {}", g.state.describe()));if let Some(l) = self.devices_line(g) {out.push(format!(" {l}"));}- out.push("== Apple ID 与签名".into());+ out.push(ictl_l10n::tr!("== Apple ID 与签名", "== Apple ID and signing").into());match self.account().selected_email().await {- Ok(_) => out.push("✅ 已登录 Apple ID".into()),+ Ok(_) => out.push(ictl_l10n::tr!("✅ 已登录 Apple ID", "✅ Signed in to an Apple ID").into()),Err(_) => {- out.push("❌ 没有登录 Apple ID\n → iphone-control login".into());+ out.push(+ ictl_l10n::tr!(+ "❌ 没有登录 Apple ID\n → iphone-control login",+ "❌ Not signed in to an Apple ID\n → iphone-control login"+ )+ .into(),+ );fails += 1;}}match &g.persisted.wda_bundle {Some(b) => {- out.push(format!("✅ WDA 已签名 {b}"));+ out.push(ictl_l10n::trf!("✅ WDA 已签名 {b}", "✅ WDA signed {b}"));// 接着手机时看手机上装的那份:最近一次签名可能是给别的手机签的if g.device.is_some() {self.refresh_device_profile(g).await;}let whose = match &g.device_profile {- DeviceProfile::Expires(_) => "这台手机上的描述文件",+ DeviceProfile::Expires(_) => {+ ictl_l10n::tr!("这台手机上的描述文件", "The provisioning profile on this phone")+ }DeviceProfile::Unknown(e) => {- out.push(format!("⚠️ 读不到手机上的描述文件({e}),下面按上次签名的记录"));- "描述文件"+ out.push(ictl_l10n::trf!("⚠️ 读不到手机上的描述文件({e}),下面按上次签名的记录", "⚠️ Can't read the provisioning profiles on the phone ({e}), going by the last signing record"));+ ictl_l10n::tr!("描述文件", "The provisioning profile")}- _ => "描述文件",+ _ => ictl_l10n::tr!("描述文件", "The provisioning profile"),};match g.device_profile.left(&g.persisted) {_ if g.device_profile == DeviceProfile::Missing => {out.push(- "❌ 这台手机上没有装当前 Apple ID 签的 WDA\n → iphone-control setup(会把这台手机注册到 Apple ID 并装上 WDA)"+ ictl_l10n::tr!("❌ 这台手机上没有装当前 Apple ID 签的 WDA\n → iphone-control setup(会把这台手机注册到 Apple ID 并装上 WDA)", "❌ No WDA signed by the current Apple ID on this phone\n → iphone-control setup (registers this phone with the Apple ID and installs WDA)").into(),);fails += 1;}Some(left) if left.is_zero() => {- out.push(format!("❌ {whose}已过期\n → iphone-control resign --force"));+ out.push(ictl_l10n::trf!(+ "❌ {whose}已过期\n → iphone-control resign --force",+ "❌ {whose} has expired\n → iphone-control resign --force"+ ));fails += 1;}Some(left) if left < Duration::from_secs(48 * 3600) => {- out.push(format!("⚠️ {whose}只剩 {} 小时 守护进程会自动重签", left.as_secs() / 3600));+ out.push(ictl_l10n::trf!(+ "⚠️ {whose}只剩 {} 小时 守护进程会自动重签",+ "⚠️ {whose} has only {} hours left the daemon re-signs automatically",+ left.as_secs() / 3600+ ));}- Some(left) => out.push(format!("✅ {whose}有效 还剩 {} 天", left.as_secs() / 86400)),- None => out.push("⚠️ 不知道描述文件什么时候到期".into()),+ Some(left) => out.push(ictl_l10n::trf!(+ "✅ {whose}有效 还剩 {} 天",+ "✅ {whose} is valid {} days left",+ left.as_secs() / 86400+ )),+ None => out.push(+ ictl_l10n::tr!(+ "⚠️ 不知道描述文件什么时候到期",+ "⚠️ Unknown when the provisioning profile expires"+ )+ .into(),+ ),}}None => {- out.push("❌ WDA 还没签名安装\n → iphone-control sign".into());+ out.push(+ ictl_l10n::tr!(+ "❌ WDA 还没签名安装\n → iphone-control sign",+ "❌ WDA not signed and installed yet\n → iphone-control sign"+ )+ .into(),+ );fails += 1;}}if let Some(r) = &g.persisted.last_resign {- out.push(format!(" 上次重签:{r}"));+ out.push(ictl_l10n::trf!(" 上次重签:{r}", " Last re-sign: {r}"));}out.push("== WDA".into());match self.wda(g) {- Some(w) if w.ready().await.unwrap_or(false) => {- out.push("✅ WDA 就绪(经 usbmuxd 直连;守护进程不监听端口,wda-bridge 运行时除外)".into())- }+ Some(w) if w.ready().await.unwrap_or(false) => out.push(+ ictl_l10n::tr!(+ "✅ WDA 就绪(经 usbmuxd 直连;守护进程不监听端口,wda-bridge 运行时除外)",+ "✅ WDA ready (directly over usbmuxd; the daemon listens on no port, except while wda-bridge runs)"+ )+ .into(),+ ),_ => {- out.push(format!("❌ WDA 不可用:{}", g.state.describe()));+ out.push(ictl_l10n::trf!("❌ WDA 不可用:{}", "❌ WDA unavailable: {}", g.state.describe()));fails += 1;}}- out.push("== 附加功能".into());+ out.push(ictl_l10n::tr!("== 附加功能", "== Extras").into());if self.cfg.notify.any() {- out.push("✅ 通知已配置".into());+ out.push(ictl_l10n::tr!("✅ 通知已配置", "✅ Notifications configured").into());} else {- out.push("⚠️ 没有配置通知 重签失败、手机离线、需要输密码时不会提醒你".into());+ out.push(ictl_l10n::tr!("⚠️ 没有配置通知 重签失败、手机离线、需要输密码时不会提醒你", "⚠️ No notifications configured you won't be alerted when re-signing fails, the phone goes offline or a passcode is needed").into());}let unlock = self.unlock_cfg(g.device.as_ref().map(|d| d.udid.as_str()));if self.cfg.legacy_passcode_file().is_file() {out.push(- "⚠️ 有一份旧版本保存的锁屏密码,没记是哪台设备的;同时接着几台时不会用它\n \-→ 在要用的设备连着时运行 iphone-control passcode set(USB 上只接着一台时会自动归到那台名下)"+ ictl_l10n::tr!("⚠️ 有一份旧版本保存的锁屏密码,没记是哪台设备的;同时接着几台时不会用它\n \+→ 在要用的设备连着时运行 iphone-control passcode set(USB 上只接着一台时会自动归到那台名下)", "⚠️ There is a passcode saved by an older version without a device; it isn't used while several devices are connected\n → run iphone-control passcode set while the device you want is connected (with only one device on USB it is assigned to it automatically)").into(),);}if unlock.disabled_by_failure() {out.push(- "❌ 自动解锁已停用(之前输错过或输入中途出错)\n → 核对密码后 iphone-control unlock-reset".into(),+ ictl_l10n::tr!("❌ 自动解锁已停用(之前输错过或输入中途出错)\n → 核对密码后 iphone-control unlock-reset", "❌ Auto-unlock is disabled (a wrong passcode or an error while entering it)\n → check the passcode, then iphone-control unlock-reset").into(),);fails += 1;} else if unlock.enabled() {- out.push("✅ 自动解锁已启用(这台设备)".into());+ out.push(ictl_l10n::tr!("✅ 自动解锁已启用(这台设备)", "✅ Auto-unlock enabled (this device)").into());} else if g.device.is_some() {- out.push("⚠️ 这台设备没设自动解锁密码 锁屏时需要人工解锁(可选:iphone-control passcode set)".into());+ out.push(ictl_l10n::tr!("⚠️ 这台设备没设自动解锁密码 锁屏时需要人工解锁(可选:iphone-control passcode set)", "⚠️ No auto-unlock passcode for this device unlock it by hand when locked (optional: iphone-control passcode set)").into());} else {- out.push("⚠️ 没接设备,看不了自动解锁".into());+ out.push(+ ictl_l10n::tr!("⚠️ 没接设备,看不了自动解锁", "⚠️ No device connected, can't check auto-unlock")+ .into(),+ );}out.push(String::new());- out.push(if fails == 0 { "全部正常".into() } else { format!("{fails} 项需要处理") });+ out.push(if fails == 0 {+ ictl_l10n::tr!("全部正常", "All good").into()+ } else {+ ictl_l10n::trf!("{fails} 项需要处理", "{fails} item(s) need attention")+ });out.join("\n")}}diff --git a/crates/ictl-daemon/src/supervise.rs b/crates/ictl-daemon/src/supervise.rsindex 7b59331..e8064c6 100644--- a/crates/ictl-daemon/src/supervise.rs+++ b/crates/ictl-daemon/src/supervise.rs@@ -426,19 +426,27 @@ impl Daemon {if g.device_profile == DeviceProfile::Missing {// 自动重签不替没装过的手机注册设备(占 Apple ID 的设备名额),交给用户决定return Ok(- "这台手机上没有装当前 Apple ID 签的 WDA,不自动重签;要装就运行 iphone-control setup".into()+ ictl_l10n::tr!("这台手机上没有装当前 Apple ID 签的 WDA,不自动重签;要装就运行 iphone-control setup", "No WDA signed by the current Apple ID on this phone, not re-signing automatically; run iphone-control setup to install it").into());}if let Some(left) = g.device_profile.left(&g.persisted)&& left > self.cfg.resign_min{- return Ok(format!("描述文件还剩 {} 小时,无需重签", left.as_secs() / 3600));+ return Ok(ictl_l10n::trf!(+ "描述文件还剩 {} 小时,无需重签",+ "{} hours left on the provisioning profile, no need to re-sign",+ left.as_secs() / 3600+ ));}}if g.resigning {- return Ok("正在重签,稍后用 iphone-control status 查看结果".into());+ return Ok(ictl_l10n::tr!(+ "正在重签,稍后用 iphone-control status 查看结果",+ "Re-signing, check the result later with iphone-control status"+ )+ .into());}- let device = g.device.clone().ok_or("手机未连接")?;+ let device = g.device.clone().ok_or(ictl_l10n::tr!("手机未连接", "Phone not connected"))?;let name = g.info.as_ref()diff --git a/crates/ictl-sign/Cargo.toml b/crates/ictl-sign/Cargo.tomlindex 93a317b..3ef5765 100644--- a/crates/ictl-sign/Cargo.toml+++ b/crates/ictl-sign/Cargo.toml@@ -10,6 +10,7 @@ homepage.workspace = truedescription = "Apple ID、描述文件、签名(含 .xctest)"[dependencies]+ictl-l10n.workspace = trueplume_core.workspace = trueplume_store.workspace = truethiserror.workspace = truediff --git a/crates/ictl-sign/src/ipa.rs b/crates/ictl-sign/src/ipa.rsindex 0043d45..874f2f7 100644--- a/crates/ictl-sign/src/ipa.rs+++ b/crates/ictl-sign/src/ipa.rs@@ -18,7 +18,12 @@ pub fn find_app(payload: &Path) -> io::Result<PathBuf> {.flatten().map(|e| e.path()).find(|p| p.extension().is_some_and(|e| e == "app"))- .ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "ipa 里没有 Payload/*.app"))+ .ok_or_else(|| {+ io::Error::new(+ io::ErrorKind::NotFound,+ ictl_l10n::tr!("ipa 里没有 Payload/*.app", "no Payload/*.app in the ipa"),+ )+ })}/// 把 `root` 下的 `Payload/` 打成 ipa@@ -35,7 +40,10 @@ pub fn from_app_zip(src: &Path, out: &Path) -> io::Result<()> {let mut zip = ZipArchive::new(File::open(src)?).map_err(io::Error::other)?;// zip 9 起条目名不合法(例如带 `..`)时给的是错误:这种条目不算if !zip.file_names().flatten().any(|n| n.split('/').next().is_some_and(|top| top.ends_with(".app"))) {- return Err(io::Error::new(io::ErrorKind::NotFound, "zip 根目录下没有 .app"));+ return Err(io::Error::new(+ io::ErrorKind::NotFound,+ ictl_l10n::tr!("zip 根目录下没有 .app", "no .app at the root of the zip"),+ ));}let mut w = ZipWriter::new(File::create(out)?);w.add_directory("Payload/", SimpleFileOptions::default().unix_permissions(0o755)).map_err(io::Error::other)?;diff --git a/crates/ictl-sign/src/lib.rs b/crates/ictl-sign/src/lib.rsindex e7b71e6..aa81311 100644--- a/crates/ictl-sign/src/lib.rs+++ b/crates/ictl-sign/src/lib.rs@@ -24,17 +24,17 @@ pub use profile::Profile;#[derive(Debug, thiserror::Error)]pub enum SignError {- #[error("还没有登录 Apple ID:运行 iphone-control login")]+ #[error("{}", ictl_l10n::tr!("还没有登录 Apple ID:运行 iphone-control login", "Not signed in to an Apple ID yet: run iphone-control login"))]NotLoggedIn,- #[error("Apple ID 会话已失效,需要重新登录(iphone-control login):{0}")]+ #[error("{}", ictl_l10n::trf!("Apple ID 会话已失效,需要重新登录(iphone-control login):{0}", "The Apple ID session expired; sign in again (iphone-control login): {0}", .0))]SessionInvalid(String),- #[error("账号下没有可用的开发团队")]+ #[error("{}", ictl_l10n::tr!("账号下没有可用的开发团队", "The account has no usable development team"))]NoTeam,- #[error("签名失败:{0}")]+ #[error("{}", ictl_l10n::trf!("签名失败:{0}", "Signing failed: {0}", .0))]Codesign(String),- #[error("开发者服务:{0}")]+ #[error("{}", ictl_l10n::trf!("开发者服务:{0}", "Developer services: {0}", .0))]Developer(String),- #[error("签名结果检查不通过:{0}")]+ #[error("{}", ictl_l10n::trf!("签名结果检查不通过:{0}", "The signed result failed verification: {0}", .0))]Verify(String),#[error("{0}")]Io(#[from] std::io::Error),@@ -152,8 +152,15 @@ impl Session {async fn sign_in(&self, work: &Path, input: &Path, output: &Path, udid: &str) -> Result<Signed> {let app = ipa::unpack(input, work)?;let bundles = bundle::collect_sorted(&app)?;- let main = bundles.last().cloned().ok_or_else(|| SignError::Codesign("空的 .app".into()))?;- let orig = main.identifier().ok_or_else(|| SignError::Codesign("主程序没有 CFBundleIdentifier".into()))?;+ let main = bundles+ .last()+ .cloned()+ .ok_or_else(|| SignError::Codesign(ictl_l10n::tr!("空的 .app", "empty .app").into()))?;+ let orig = main.identifier().ok_or_else(|| {+ SignError::Codesign(+ ictl_l10n::tr!("主程序没有 CFBundleIdentifier", "the main executable has no CFBundleIdentifier").into(),+ )+ })?;let team = &self.team_id;let new_id = if orig.ends_with(&format!(".{team}")) { orig.clone() } else { format!("{orig}.{team}") };@@ -169,11 +176,12 @@ impl Session {b.set_identifier(&id)?;let name = b.name().unwrap_or_else(|| id.clone());self.inner.qh_ensure_app_id(team, &name, &id).await?;- let app_id = self- .inner- .qh_get_app_id(team, &id)- .await?- .ok_or_else(|| SignError::Developer(format!("刚创建的 App ID {id} 查不到")))?;+ let app_id = self.inner.qh_get_app_id(team, &id).await?.ok_or_else(|| {+ SignError::Developer(ictl_l10n::trf!(+ "刚创建的 App ID {id} 查不到",+ "The App ID {id} that was just created can't be found"+ ))+ })?;let data = self.inner.qh_get_profile(team, &app_id.app_id_id).await?.provisioning_profile.encoded_profile;let data: Vec<u8> = data.as_ref().to_vec();// 合并 entitlements 后在下面签名前写进 bundle@@ -218,21 +226,40 @@ pub fn verify_signed(app_dir: &Path, udid: &str, signing_cert: Option<&[u8]>) ->continue;}if !b.dir.join("_CodeSignature/CodeResources").is_file() {- return Err(SignError::Verify(format!("{} 没有签名", b.dir.display())));+ return Err(SignError::Verify(ictl_l10n::trf!("{} 没有签名", "{} is not signed", b.dir.display())));}}- let p = Profile::load(&app_dir.join("embedded.mobileprovision"))- .ok_or_else(|| SignError::Verify("主程序没有可解析的 embedded.mobileprovision".into()))?;+ let p = Profile::load(&app_dir.join("embedded.mobileprovision")).ok_or_else(|| {+ SignError::Verify(+ ictl_l10n::tr!(+ "主程序没有可解析的 embedded.mobileprovision",+ "the main executable has no readable embedded.mobileprovision"+ )+ .into(),+ )+ })?;if !p.devices.iter().any(|d| d == udid) {- return Err(SignError::Verify("描述文件里没有这台手机,先注册设备".into()));+ return Err(SignError::Verify(+ ictl_l10n::tr!(+ "描述文件里没有这台手机,先注册设备",+ "this phone is not in the provisioning profile; register the device first"+ )+ .into(),+ ));}if !p.get_task_allow {- return Err(SignError::Verify("描述文件不带 get-task-allow,WDA 起不来".into()));+ return Err(SignError::Verify(+ ictl_l10n::tr!(+ "描述文件不带 get-task-allow,WDA 起不来",+ "the provisioning profile lacks get-task-allow, WDA won't start"+ )+ .into(),+ ));}if let Some(der) = signing_cert&& !p.certificates.iter().any(|c| c == der){- return Err(SignError::Verify("描述文件里没有签名用的证书(证书在描述文件生成后才换过),手机会拒装".into()));+ return Err(SignError::Verify(ictl_l10n::tr!("描述文件里没有签名用的证书(证书在描述文件生成后才换过),手机会拒装", "the provisioning profile doesn't contain the signing certificate (the certificate changed after the profile was created); the phone would refuse to install it").into()));}Ok(p)}